https://pantsbuild.org/ logo
#general
Title
# general
b

bland-father-19717

08/11/2022, 10:57 AM
Is it possible to create base docker image A with skip_push=True and use it as
FROM A
in another docker_image?
base image a
BUILD file
Copy code
docker_image(
    name="ffmpeg-python",
    skip_push=True,
    source="Dockerfile.ffmpeg-python"
)
another image
BUILD file
Copy code
docker_image(
    name="image",
    dependencies=[
        "src/docker:ffmpeg-python",
    ],
    repository="xxx"
    image_tags=[
        "xxx"
    ],
)
Dockerfile
Copy code
FROM ffmpeg-python
https://pantsbuild.slack.com/archives/C046T6T9U/p1659029713975069 Some users seem to be able to do something similar, but I don’t know if they are setting skip_push=True, so it may be different. In this example, I am wondering what the contents of the BUILD file for
base_docker_gpu
would look like if it were successful.
b

bitter-ability-32190

08/11/2022, 12:31 PM
My favorite answer is always "try it and find out". But the true answer is yes
You just need the right name on the FROM statement
I wrote a blog post about some optimizations, it uses this technique. Last code block https://blog.pantsbuild.org/optimizing-python-docker-deploys-using-pants/
b

bland-father-19717

08/11/2022, 12:39 PM
Actually, I have tried the following based on that blog, but it does not work.
Copy code
docker_image(
    name="ffmpeg-python",
	repository="ffmpeg-python",
	registries=["companyname"],
    image_tags=["latest"],
    skip_push=True,
    source="Dockerfile.ffmpeg-python"
)
Copy code
docker_image(
    name="test",
    dependencies=[
        "src/docker:ffmpeg-python",
    ],
    source=None,
    instructions=[
        "FROM companyname/ffmpeg-python:latest",
    ],
    repository="{build_args.AWS_ECR_ACCOUNT_URL}/task/{parent_directory}/{directory}",
    image_tags=[
        "{build_args.COMMIT_SHA1}",
        "{build_args.BRANCH}_{build_args.BUILD_NUM}",
    ],
)
error message
#3 [internal] load metadata for docker.io/companyname/ffmpeg-python:latest
#3 sha256:87c69fae016e9adea7828622176eb11fca1f861a80780b53b6c1205289cc4142
#3 ...
#4 [auth] companyname/ffmpeg-python:pull token for registry-1.docker.io
#4 sha256:224e02fd2e52c17aae669437d827ed05f39e67c4064dd49b19651e5be026c0ac
#4 DONE 0.0s
#3 [internal] load metadata for docker.io/companyname/ffmpeg-python:latest
#3 sha256:87c69fae016e9adea7828622176eb11fca1f861a80780b53b6c1205289cc4142
#3 ERROR: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
------
> [internal] load metadata for docker.io/companyname/ffmpeg-python:latest:
------
failed to solve with frontend dockerfile.v0: failed to create LLB definition: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
b

bitter-ability-32190

08/11/2022, 12:49 PM
There's a bug in Pants 2.13 with docker building order, where it doesn't always build the parent. It's been fixed but idk if it's been cherry picked. @happy-kitchen-89482?
b

bland-father-19717

08/11/2022, 12:51 PM
The version of pantsbuild I am using is 2.12.0.
b

bitter-ability-32190

08/11/2022, 12:58 PM
That has the bug too I presume
👌 1
So it should work, but there's corner cases with bugs 🙈
h

happy-kitchen-89482

08/11/2022, 1:28 PM
Yeah, that was cherry-picked to 2.13
but has not been released yet
Sorry for the inconvenience!
👍 1
b

bitter-ability-32190

08/11/2022, 1:28 PM
Should it be picked to 2.12?
h

happy-kitchen-89482

08/11/2022, 1:34 PM
Possibly
I’ll see if it’ll pick cleanly
❤️ 1
ish
b

bland-father-19717

08/28/2022, 6:34 AM
Hi! I have updated the pant.toml, but I get the same error. What should I do with the BUILD file?
Copy code
[GLOBAL]
pants_version = "2.12.1rc4"
8 Views