buildkite-plugins / docker-compose-buildkite-plugin

🐳⚡️ Run build scripts, and build + push images, w/ Docker Compose
MIT License
171 stars 138 forks source link

Pulling a docker image from a different pipeline #403

Closed amit-nayar closed 11 months ago

amit-nayar commented 1 year ago

Not sure how to ask this without creating an issue.

Is is possible to Pre-build/cache an image on one pipeline, say one that runs on master whenever a commit is added, and pull that cached image on another pipeline without having to declare it in the same set of steps?

So something like this:

Pipeline 1 yml - build and push docker image (runs on master)

steps:
  - label: ':docker: Build & Push Image'
    plugins:
      - docker-compose#v4.12.0:
          config: 'my-compose.yml'
          build: 'myapp'
          image-repository: 'repo.com'
          image-name: '$DOCKER_IMAGE_TAG'
          cache-from:
            - 'myapp:repo.com:$DOCKER_IMAGE_TAG'
            - 'myapp:repo.com:latest'

pipeline 2 yml - tests - run on each PR

  - label: 'test 1'
    command: 'test.sh'
    plugins:
      - docker-compose#v4.12.0:
          run: 'myapp'
          config: 'my-compose.yml'

  - label: 'test 2
    command: 'test2.sh'
    plugins:
      - docker-compose#v4.12.0:
          run: 'myapp'
          config: 'my-compose.yml'

I have tried this approach but it is trying to build the image each time on the tests pipeline.

pzeballos commented 11 months ago

Hey @amit-nayar! No worries, you can create a new issue with questions/doubts 🙂 Nope 😔 that's not possible with the docker-compose plugin, and would be out of the scope of plugins.