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):
Searching for files matching artifact pattern foobar-dockerimg.tar
Artifact pattern foobar-dockerimg.tar matched 1 files with a total size of 205 MiB
Compressed files matching artifact pattern foobar-dockerimg.tar to 167 MiB in 9 seconds
Uploading artifact of 167 MiB
Successfully uploaded artifact in 9 seconds
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:
Artifact "foobar-dockerimg.tar": Downloading
Artifact "foobar-dockerimg.tar": Downloaded 167 MiB in 5 seconds
Artifact "foobar-dockerimg.tar": Extracting
Artifact "foobar-dockerimg.tar": Extracted in 1 seconds
Unfortunately, the `docker load --input ./foobar-dockerimg.tar` command in the second step always fails with the message:
+ docker load --input ./foobar-dockerimg.tar
open ./foobar-dockerimg.tar: no such file or directory
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?
On a related note, I tried replacing the docker image .tar file with a vanilla text file (so, in Step #1 the artifact is created via `touch foobar.txt` and I add some data via `echo "some data" >> foobar.txt`. This foobar.txt file artifact is successfully delivered to my build workspace on Step #2.
The fact that the foobar.txt file is being delivered properly on Step #2 suggests that my general approach to publishing and consuming artifacts between steps is valid. I suspect one of two things is going on:
Of course, I could also be missing something obvious. But my approach here is based on the Docker example provided by Bitbucket, so I'm not sure what I could be doing wrong.
Same exact thing is happening with me.
End of the build output:
Successfully built a9da703464ce
Successfully tagged blahbuild:0.1.1
mkdir ./build-artifacts
docker save -o build-artifacts/blahbuild_0.1.1.tar blahbuild:0.1.1
dir -ls build-artifacts/*
15238784 -rw------- 1 root root 15604507648 Jun 10 19:37 build-artifacts/blahbuild_0.1.1.tar
As you can see the tar file is 15GB.
Nothing in the Artifacts tab.
Probably the size.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.