Hey folks! I’m trying to follow the example from <...
# general
b
Hey folks! I’m trying to follow the example from this blog post to split my PEX + Docker builds into multiple images. I managed to get everything running through “Multi-stage build leveraging 2 PEXs”, but have some trouble with the last step in “Multiple Images and tagging”. I’m able to get the
srcs
and
deps
images to build correctly, but when trying to build the final combined image I get the following error:
Copy code
#3 [internal] load metadata for myrepo:srcs
#3 ERROR: myrepo:srcs: not found
But when I run
docker images
, the images definitely exist:
Copy code
myrepo          deps            491bcdc66b66   23 hours ago         560MB
myrepo          srcs            5b5af6a920cd   23 hours ago         159MB
Is there some other step I forgot before building the final image?
Here’s my BUILD file:
Copy code
docker_image(
    name="img-deps",
    registries=[],
    repository="myrepo",
    image_tags=["deps"],
    skip_push=True,
    instructions=[
        "FROM --platform=linux/amd64 python:3.10-slim AS deps",
        "COPY api.src.py.api/binary-deps.pex /binary-deps.pex",
        "RUN PEX_TOOLS=1 /usr/local/bin/python3.10 /binary-deps.pex venv --scope=deps --compile /bin/app",
    ]
)

docker_image(
    name="img-srcs",
    registries=[],
    repository="myrepo",
    image_tags=["srcs"],
    skip_push=True,
    instructions=[
        "FROM --platform=linux/amd64 python:3.10-slim as srcs",
        "COPY api.src.py.api/binary-srcs.pex /binary-srcs.pex",
        "RUN PEX_TOOLS=1 /usr/local/bin/python3.10 /binary-srcs.pex venv --scope=srcs --compile /bin/app",
    ]
)

docker_image(
    name="img",
    dependencies=[":img-srcs", ":img-deps"],
    registries=["@aws"],
    repository="myrepo",
    image_tags=["{build_args.TAG}"],
    instructions=[
        "FROM --platform=linux/amd64 python:3.10-slim",
        "RUN apt-get update && apt-get install -y procps build-essential python3-dev libpq-dev",
        'ENTRYPOINT ["/bin/app/pex"]',
        "COPY --from=myrepo:srcs /bin/app /bin/app",
        "COPY --from=myrepo:deps /bin/app /bin/app",
        "EXPOSE 80",
    ],
)
b
oh whoops. Bug in the blog post 🙂
FYI @happy-kitchen-89482 we should edit the blog post. Last code block should say:
Copy code
instructions = [
    	    "FROM companyname/app:deps as deps",
    	    "FROM companyname/app:srcs as srcs",
            "FROM python:3.10-slim",
    	    'ENTRYPOINT ["/bin/app/pex"]',
    	    "COPY --from=deps /bin/app /bin/app",
    	    "COPY --from=srcs /bin/app /bin/app",
	]
@better-van-82973 try that 🙂
b
Thanks for the fast response! Will give it a go
Also thanks for the blog post - my cold start times went way down after implementing a bunch of the stuff you mention there 🙂
❤️ 1
b
What's mine is yours :)
b
That worked! Thanks Josh
h
@bitter-ability-32190 Are you able to edit the post?