简体   繁体   中英

Have Concourse only build new docker containers on file diff not on commit

So I have a pipeline that builds multiple docker containers from a single git repo. It looks something like this:

---
resources:
- name: resource-docker
  type: git
  source:
    uri: https://github.com/$MYUSER/$MYREPO.git
    branch: master

# docker-image resources
- name: first-container
  type: docker-image
  source:
    repository: $MYUSER/first-container

- name: second-container
  type: docker-image
  source:
    repository: $MYUSER/second-container

jobs:
# image-update jobs
- name: first-container-image-update
  public: true
  serial_groups:
    - serial_lock
  plan:
  - get: resource-docker
    serial: true
  - put: first-container
    params:
      build: resource-docker/first-container-path

- name: second-container-image-update
  public: true
  serial_groups:
    - serial_lock
  plan:
  - get: resource-docker
    serial: true
  - put: second-container
    params:
      build: resource-docker/second-container-path

The problem is that running a resource-docker task is taking up a significant portion of system resources and rebuilding the containers from scratch on each commit to the master (which contains more code than just the docker containers).

I would like to make these tasks instead compare the old and new files used to build the containers, and only rebuild a container if there is a diff in the files.

Note: that separating the files out into different repos is an option I want to avoid.

your resource can be configured to trigger new builds only with changes to specific files in the repo:

- name: resource-docker
  type: git
  source:
    uri: https://github.com/$MYUSER/$MYREPO.git
    branch: master
    paths:
      - <path/to/Dockerfile/or/whatever>
      - <path/to/other/triggering/diffs>

In case Quintana's answer isn't totally clear, the idea is you can define multiple Git resources which point at the same Git repository. Each resource can use paths / ignore_paths to specify which filed to look at.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM