Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Cannot consume created files in docker build

rupert160 February 4, 2024

I have a single step that creates some files and attempts to pull these into a docker container using `docker build`

my `bitibucket-pipeline.yml` file is:

pipelines:
default:
- step:
name: certificates
oidc: true
image:
name: 242011367797.dkr.ecr.ap-southeast-2.amazonaws.com/datallama/bitbucket_pipeline:0.3
aws:
oidc-role: arn:aws:iam::242011367797:role/dl_ecr_admin
script:
- bash ui/fixcerts.sh --pipeline
- ls ${BITBUCKET_CLONE_DIR}
- find "$(pwd -P)/certs" -name "server*"
- docker build --tag 242011367797.dkr.ecr.ap-southeast-2.amazonaws.com/datallama/test/dlmvp_657/ui:${BITBUCKET_BUILD_NUMBER} /opt/atlassian/pipelines/agent/build/ui
services:
- docker

and the `ui/Dockerfile` is:

FROM httpd:2.4.41 AS uiinit
COPY certs/server.crt /usr/local/apache2/conf/server.crt
EXPOSE 80 443
CMD ["httpd-foreground"]

the full path to the certs/server.crt file is: /opt/atlassian/pipelines/agent/build/certs/server.crt

and the error I get for the build is on the `COPY` statement where the server.crt cannot be picked up from /var/lib/docker/165536.165536/tmp/buildkit-mount3275278172/certs: no such file or directory

I've also tried using artifacts and i have also failed to consume files in docker builds.

pipelines:
default:
- step:
name: certificates
oidc: true
image:
name: 242011367797.dkr.ecr.ap-southeast-2.amazonaws.com/datallama/bitbucket_pipeline:0.3
aws:
oidc-role: arn:aws:iam::242011367797:role/dl_ecr_admin
script:
- bash ui/fixcerts.sh --pipeline
- ls certs
artifacts:
- certs/**
- step:
name: build
oidc: true
image:
name: 242011367797.dkr.ecr.ap-southeast-2.amazonaws.com/datallama/bitbucket_pipeline:0.3
aws:
oidc-role: arn:aws:iam::242011367797:role/dl_ecr_admin
script:
- cd $BITBUCKET_CLONE_DIR && pwd && find "$(pwd -P)" -name "server*" && cd -
- find "$(pwd -P)/certs" -name "server*"
- docker build --tag 242011367797.dkr.ecr.ap-southeast-2.amazonaws.com/datallama/test/dlmvp_657/ui:${BITBUCKET_BUILD_NUMBER} /opt/atlassian/pipelines/agent/build/ui
services:
- docker

However this fails for the same reason:/var/lib/docker/165536.165536/tmp/buildkit-mount1013567659/certs: no such file or directory

 Is there a special context I need to use for passing files to bulid containers? How can I COPY files in a `docker build` command?

1 answer

0 votes
rupert160 February 4, 2024

I had a relative directory issue, placing the `certs` directory within the `ui` directory made the build relative to `docker build` command whist it was visible to the pipeline, it wasn't visible to docker.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events