Search code examples
dockerconcourse

Concourse: cannot access job resources during put step


I am trying to have a job create and push a docker image that contains my application's dependencies using the build parameter. In the concourse docs it states that all resources that have been fetched via get are available during a put step. I don't seem to be able to access my git resource however in order to pull the pom.xml file from it. When I try to run this job I get an error that pom.xml file does not exist.

pipeline job

  - name: get-dependencies
    plan:
    - get: git-repo
      passed: [pull-repo]
      trigger: true
    - get: artifacts-container
    - put: artifacts-container
      params:
        inputs: [git-repo]
        build: git-repo/app/concourse/dockerfiles/artifacts

Dockerfile

# Set base image qualities
FROM localhost:5000/app-artifacts:0.0.3 AS build

Load application into image
COPY git-repo/app/pom.xml /

RUN mvn dependency:go-offline 

Solution

  • I had a similar Problem. I wanted to build a docker image and put a folder from a different resource into that image using the COPY Command.

    First i gave the docker-image-resource only the "build" parameter with the folder where the Dockerfile lives. But that way i was unable to access the other-resource I ended up using a both the 'build' and the 'dockerfile' parameter. That way the build happens in the root of the put step and all other artefacts are available.

    My Pipeline:

    - put: docker-image-resource
      params:
        build: .
        dockerfile: ./path/to/Dockerfile
        build_args:
          CONFIG_DIR: ./other-resource/
    

    I have furhter used a build-arg to decouple the Dockerfile from the pipelines build. So i can be able to pecify other directories in other build context (e.g. local).