To build and push containers with Sail CI you can use Kaniko as a task within your pipeline.
Kaniko is a tool to build and push container images from a Dockerfile. It does not depend on the Docker daemon and executes each command within a Dockerfile entirely in userspace.
Find more information at:
- /root/.docker/config.json: DOCKER_AUTH
We can mount the Docker auth credentials json saved as an environment variable (using DOCKER_AUTH as the key) via https://app.sail.ci. It is mounted to the filesystem at the default credentials /root/.docker/config.json. As this is the default location for Docker hub credentials when using Kaniko no further steps are required.
See https://sail.ci/docs/mounts for more information on mounts.
A typical Docker hub auth
Note: The auth property is a base64 encoded value in the format:
You can typically base64 encode a string using:
echo -n "username:password" | base64
-n is important to ensure no trailing newline exists within the encoded value.
The "build-push" task uses the official Kaniko image from Google to then specify a context to build the Docker image (in this example the Dockerfile is at the root of the project). A --destination argument provides Kaniko with the registry to push the image once built.