Hi,
I am trying to build a docker image in one step, and then deploy it to a container registry in another step. I am following the example laid out in Bitbucket pipeline Validator. My steps look like this:
- step: &build-docker-image
name: Build Docker Image
caches:
- maven
- docker
- node
script:
- ./mvnw verify -Pprod -DskipTests
- WARFILE=( "target"/*.war )
- echo $WARFILE
- cp $WARFILE src/main/docker/app.war
- docker build -t foobar -f src/main/docker/Dockerfile src/main/docker
- docker save foobar --output foobar-dockerimg.tar
services:
- docker
artifacts:
- foobar-dockerimg.tar
...
This step runs successfully, and the output indicates that it has successfully stored the artifact (the artifact is also available for download in the Artifacts tab for the Step):
<span>Searching for files matching artifact pattern foobar-dockerimg.tar</span><span>Artifact pattern foobar-dockerimg.tar matched 1 files with a total size of 205 MiB</span><span>Compressed files matching artifact pattern foobar-dockerimg.tar to 167 MiB in 9 seconds</span><span>Uploading artifact of 167 MiB</span><span>Successfully uploaded artifact in 9 seconds</span>
This is the second task that needs to use the artifact to publish:
- step: &publish-docker-img-prodcr
name: Publish Artifacts -> Prod CR
caches:
- maven
- docker
- node
script:
- echo "*** Publishing Application Version:${CVC_APP_VERSION} to ${AZ_CR_SERVER_PROD}"
- ls -lah
- pwd
- docker login $AZ_CR_SERVER_PROD -u "$AZ_CR_USER_PROD" -p "$AZ_CR_PASSWORD_PROD"
- docker load --input ./foobar-dockerimg.tar
- ... publishing stuff...
services:
- docker
artifacts:
- foobar-dockerimg.tar
When the step executes, the "Build setup" output indicates that it has successfully downloaded my artifact:
<span>Artifact "foobar-dockerimg.tar": Downloading</span><span>Artifact "foobar-dockerimg.tar": Downloaded 167 MiB in 5 seconds</span><span>Artifact "foobar-dockerimg.tar": Extracting</span><span>Artifact "foobar-dockerimg.tar": Extracted in 1 seconds</span>
Unfortunately, the `docker load --input ./foobar-dockerimg.tar` command in the second step always fails with the message:
<span>+ docker load --input ./foobar-dockerimg.tar</span>
<span>open ./foobar-dockerimg.tar: no such file or directory</span>
The `ls -lah` command in the step confirms that the foobar-dockerimg.tar artifact is not available in the build directory (i.e. this doesn't appear to be an issue with the `docker load` command.
Is there something I am missing with respect to how artifacts work? Am i doing anything obviously wrong here?