I'm going to be building various docker images bas...
# general
l
I'm going to be building various docker images based on an entry point of a given module in a Python project, but I also need to build a pair of images that only rely on third party dependencies. I could just write a Dockerfile that does that, but I would prefer to rely on the poetry lock file in the repo, so I was going to try to have Pants handle that build as well. How do I tell it to install those third-party requirements? What I've got so far (doesn't do what I need yet) is this:
Copy code
docker_image(
    name="ol-dagster-daemon",
    dependencies=[
        "//:requirements#dagster",
        "//:requirements#dagster-postgres",
    ],
    instructions=[
        "FROM python:3.9-slim",
        "WORKDIR /opt",
        "COPY . .",
    ]
)
@curved-television-6568 you might know the answer to this one ^ (or @witty-crayon-22786)
🙂 1
w
hey @limited-insurance-37393
l
Greetings
w
to put requirements in a docker container, you’ll need to choose a packaging format (most likely, that would be a
pex_binary
currently), and then make the package a direct dependency of the docker image. you might have been expecting that these deps would be installed in a virtualenv inside the image, perhaps? but currently, you’d need to package, and then extract into a virtualenv inside the image
l
It doesn't need to be a virtualenv, I was just trying to think of how to re-use the version locks from the repository for pinning the dependencies in the image
👍 1
So, just to make sure I'm understanding the steps here, I would add a
pex_binary
target that relies on those third party dependencies and give it the entrypoint that I would use for the Docker execution?
1
h
yes, I believe so. Example project https://github.com/pantsbuild/example-docker
l
👍 thanks
c
Stu and Eric beat me to it :)
❤️ 1