Git 让Concourse仅在文件diff而不是提交时构建新的docker容器

Git 让Concourse仅在文件diff而不是提交时构建新的docker容器,git,docker,concourse,Git,Docker,Concourse,所以我有一个管道,可以从一个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 sourc

所以我有一个管道,可以从一个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
问题在于,运行
资源docker
任务占用了系统资源的很大一部分,并在每次提交给主服务器时从头开始重建容器(其中包含的代码比docker容器多)

我想让这些任务比较用于构建容器的新旧文件,并且仅在文件中存在差异时重建容器


注意:我想避免将文件分离到不同的repo中。

您的资源可以配置为仅在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>
-名称:资源docker
类型:git
资料来源:
uri:https://github.com/$MYUSER/$MYREPO.git
分支机构:硕士
路径:
- 
- 

如果Quintana的答案不完全清楚,那么您可以定义多个指向同一Git存储库的Git资源。每个资源都可以使用
路径
/
忽略路径
来指定要查看的字段。

是的,这实际上是我最后要做的。创建同一repo的多个git资源,每个都指定了不同的路径。