2

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.

Alex Cohen
  • 5,596
  • 16
  • 54
  • 104

2 Answers2

4

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>
qqq
  • 1,360
  • 1
  • 9
  • 24
2

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.

mkb
  • 21
  • 1
  • Yea that is actually ehat I wound up doing. Creating several git resources of the same repo, each with a different path specified. – Alex Cohen Dec 06 '16 at 19:44