I'm running a TeamCity agent that spawns a docker container, running several tasks inside that (php) container. Such as phpunit, phplint and composer. I zipped the content inside the container if all tests pass, it will create a phpproject.zip.
After it's done I would like to push that phpproject.zip as an Artifact back to the TeamCity server from inside the docker container.
My docker container is running with the --rm parameters to remove the container after the script is done.
Is this possible?
Tim
Steps: Add task docker->switch the task version to 0->select the option Run a Docker command , then we could run the docker save command, check the pic below. Is there any better way of doing this apart from saving an image. We recommend that you use this to upload the docker image as an artifact.
If you modify the contents of a container, you can use the docker commit command to save the current state of the container as an image.
You can map a volume of the Docker daemon to the container with the -v
parameter and publish the artifacts to the daemon:
...
# Your build path and build command here
VOLUME /foo/build
ENTRYPOINT make
In TeamCity, configure a Docker build step to build the Dockerfile, and name:tag the resulting image. Add a second step in which you configure an other... Docker command as run
, with the arguments:
-v /tmp/build:/foo/build --rm <name of image>
The result is then available in /tmp/build
on the agent, and you can configure that as artifact path in the project's settings, or alternatively echo "##teamcity[publishArtifacts '/tmp/build']"
somewhere.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With