所以我有一个管道,可以从一个 git repo 构建多个 docker 容器。它看起来像这样:
---
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
问题是运行resource-docker
任务会占用很大一部分系统资源,并且每次提交到主服务器时都从头开始重建容器(其中包含更多代码,而不仅仅是 docker 容器)。
我想做这些任务,而不是比较用于构建容器的新旧文件,并且只有在文件中有差异时才重建容器。
注意:将文件分成不同的存储库是我想避免的一个选项。