We suppose two main CI/CD scenarios for Docker:
Automated Docker builds: All image dependencies already exist and all you need is to build and publish a Docker image.
Creating dependencies before the build: An Automation job must create image dependencies before building and publishing the image.
Space Automation DSL provides a special
docker keyword that simplifies working with Docker builds.
Build and publish a Docker image
For example, the job below first builds and then publishes the image defined in the
Dockerfile located in the project's
docker: is a special step used to build and publish Docker images. In fact, it's a special type of container with Docker on board.
build: runs the
docker buildcommand with the following arguments
push: runs the
docker pushcommand with the following arguments
Create an image dependency, build, and publish a Docker image
Quite often, you may need to first generate some artifact (say, a .jar file) and then put it into an image. Such cases require running two steps: The first generates the artifact and the second one runs
docker build and
gradlew buildto generate some artifacts and put them to the file share.
resourcesspecifies system resources as in a regular container.
beforeBuildScriptis a sub-step that runs before
build. Here we use
beforeBuildScriptto copy the Gradle output from the file share to the context directory.
pushbuild and push the image correspondingly.