Reputation: 5155
I am trying to use a Concourse pipeline to pull a git repo and then build/push a Docker image from the dockerfile in the git repo. The dockerfile has a COPY command in it to copy files from the repo into the image. Normally I'd mount a volume to be able to COPY those files in at build time, but not finding a way to do that in Concourse. Here's what I'm trying:
# pipeline.yml
resources:
- name: git-repo
type: git
source:
uri: <the-git-url>
branch: master
private_key: ((source-git-ssh-key))
- name: my-image
type: docker-image
source:
repository: gcr.io/path_to_image
username: _json_key
password: ((gcp-credential))
jobs:
...
- get: git-repo
trigger: true
- put: my-image
params:
build: git-repo/compose
# dockerfile located at git-repo/compose/Dockerfile
FROM ...
...
# git-repo/scripts/run-script.sh
COPY scripts/run-script.sh /
...
How can I make the file git-repo/scripts/run-script.sh available to be copied into my image at build time? Thank you.
Upvotes: 0
Views: 1587
Reputation: 5155
Found a way. The build context is assumed to be the base dir (e.g. git-repo/compose
in the example). As a result, the files I wanted to copy in were outside the directory I had available. If your Dockerfile isn't in the root dir, you need to specify it in the dockerfile
param if you still want access to the rest of the same/higher-level files. Working example:
- put: my-image
params:
build: git-repo
dockerfile: git-repo/compose/Dockerfile
Upvotes: 0
Reputation: 311606
I'm not familiar with Concourse, but as a rule with Docker you can only COPY
things into your image that are contained in your build context (that is, they are in the build directory or a subdirectory of the build directory). From you configuration file...
- put: my-image
params:
build: git-repo/compose
It looks like your build context is git-repo/compose
. Since the script you want to include is outside of that directory (git-repo/scripts/run-script.sh
), it's not going to be available during the build process.
The solution is to reorganize your git-repo
. For example, you could:
scripts/
directory into your compose/
directory.Dockerfile
out of compose/
and into the main git-repo
directory.Upvotes: 1