Is there anything that forbids setting Docker imag...
# general
b
Is there anything that forbids setting Docker images as dependencies for a pex_binary? I am asking because I am using Pants to build an AWS CDK application that depends on a few Docker images for deployment. I have tried to specify the dependencies as shown below, but for some reason, the Docker images are not built automatically when I build the pex_binary:
Copy code
python_sources()

resources(name="cdk_file", sources=["cdk.json"])

pex_binary(
    name="my-cdk-app-cdk",
    entry_point="app.py",
    execution_mode="venv",
    venv_site_packages_copies=True,
    dependencies=[
        ":cdk_file",
        "src/my_app/api_lambda:api_lambda",
    ],
)
c
The problem is that adding the docker container as a dependency doesn't add the result of
pants package
as a dependency. If I understand your usecase correctly: your pex_binary is IAC (using CDK) that deploys resources in AWS which reference docker containers that are also built by Pants. You'd like it that when you run the script, Pants will
package
(and
publish
?) the docker targets
b
That is exactly what I want. I can do it manually, but using pants to build each of the containers, then the CDK app, and then run the CDK app (which parses the docker json output from pants to know where the docker images are stored). I would basically want the docker images to be built automatically when I build the CDK application.
b
I think one technique people use is to have the deploy scripts run the appropriate
pants pcakage
(and/or
publish
itself) internally. It's not super great... but might work for this? Something like running
pants package path/to:my-cdk-app-cdk && dist/path.to/my-cdk-app-cdk.pex
c
Ah, yeah, I think this isn't supported yet. The
experimental-deploy
goal has the concept of "publish_dependencies" for targets to publish before running the deployment. The helm backend does this for identified docker containers. I imagine we could do something like the adhoc backend but for the
experimental-deploy
, which would run an arbitrary `run`able...