You can push images from your CI/CD system to DigitalOcean Container Registry. For example, you can push a new image to the registry whenever a build with your commit is successful on your source control system.
To start using your CI/CD system with the registry, you first need to authenticate it to push images to the registry. Depending on your CI system, you can use one of the following methods to authenticate it:
You can then run the
docker commands to push your image to the registry or you can configure your CI system to specify what to build and push the image automatically.
Many CI systems support configuring authentication using a Docker
config.json file. You can fetch this JSON file for your container registry using one of the following methods:
doctl registry docker-config --read-write. If you do not provide the
--read-writeflag, you will receive read-only credentials, which are usually undesirable for CI.
For CI systems that support configuring registry authentication via username and password, use a DigitalOcean API token as both the username and the password. The API token must have read/write privileges to push to your registry.
If you can run
doctl in your CI environment, run the following command to authenticate before pushing images:
doctl registry login --expiry-seconds <time>
This method is a good choice for CI systems such as GitHub Actions, where you can run arbitrary commands and push Docker images via the Docker command-line. For an example, see Enable Push-to-Deploy.