I'm in the process of adopting pants and one of th...
# general
g
I'm in the process of adopting pants and one of the last things I need to do is figure out how to integrate with docker compose. Most of the Dockerfile's were brought directly into BUILD files. Do I need to revert this or is there a better option?
c
Is the question about using docker compose with pants built docker images? Or having compose invoke pants to build the images?
g
well, it's more like today they would invoke docker compose which would trigger docker builds because they compose files are pointing at both image refs and Dockerfiles directly.
So the question is, how can I resume this same pattern? I would assume with adhoc tool and system_binary potentially?
I just don't want to assume here. I'd love experienced input 🙂
for example...
Copy code
services:
  app-api:
    env_file: ./apps/app-api/.env
    build: &app-api-build
      dockerfile: apps/app-api/Dockerfile
      target: dev
      args:
        DOCKER_BUILDKIT: 1
c
All of our docker-compose files are for pytest fixtures, so they look like
Copy code
services:
  partner_file_drop:
    image: ecr_shared_services/app:${IMAGE_TAG:-localdev}
    ports:
      - 3000
      - 9090
Which is "works" but I don't think is a typical compose workflow
g
gotcha.
m
@curved-manchester-66006’s suggestion will work with plain ol' docker compose, but you'd need a way to force
pants package
to run before running the docker-compose command (perhaps an adhoc_tool?)
The way we make it work, is we add the docker targets as runtime_package_dependencies, and use pytest-docker to spin up manage docker-compose
(this is for integration tests, not running docker-compose locally)
g
Thanks
c
Not sure if useful, but you can get the Dockerfiles by running “pants codegen-export …” or something along those lines. (Drawing from memory) they’ll end up under dist/…
🙌 1
g
@curved-television-6568 that is helpful
👍 1