DigitalOcean Container Registry
Push Docker images to your DigitalOcean Container Registry with pipeline integration
You can configure DigitalOcean Container Registry as your Docker Registry, and use it in your Codefresh pipeline.
The DigitalOcean Container Registry is directly integrated into your DigitalOcean Dashboard. While it is optional to use the DigitalOcean Container registry with your DigitalOcean Kubernetes cluster, it allows for easier integration between resources.
The next sections will look at:
- Creating the DigitalOcean Container Registry
- Generating a DigitalOcean Access token
- Adding the DigitalOcean Container Registry to our Docker Registry in Codefresh
- Modifying the Build step in our Codefresh pipeline
- Viewing the built image in the DigitalOcean Container Registry
Building and pushing a container image with DigitalOcean and Codefresh
Building and pushing a container image with DigitalOcean and Codefresh, requires:
- A DigitalOcean account (your GitHub username)
- A DigitalOcean access token
- An application with a Dockerfile to build images
Creating the DigitalOcean Container Registry
Once you are logged into your DigitalOcean Account, open the
Container Registry tap and provide the name of your registry. Note that the name has to be unique.
Creating an access token
Now that we are already in DigitalOcean, we have to create an access token. Note that it requires read and write access.
Select API at the bottom right of your left-side menu under Tokens/Keys.
Copy and paste the token somewhere secure and where you will find it again.
Set up DigitalOcean Container Registry integration
- In the Codefresh UI, on the toolbar, click the Settings icon, and then from the sidebar, select Pipeline Integrations.
- Select Docker Registries and then click Configure.
- From the Add Registry Provider dropdown, select Other Registries.
- Define the following:
- Registry name: A unique name for this configuration.
- Username: The DigitalOcean access token you created.
- Password: The DigitalOcean access token you created.
Optional, you can add your registry name to the advanced settings section. For instance, if you named it in Digital Ocean “anais-codefresh”, you can ensure that every time the registry is used, it is automatically referenced in the build step of your pipeline.
- To verify the connection details, click Test Connection.
- To apply the changes, click Save.
Modify your build step
Within your Codefresh YAML file, modify the build step to push to the DigitalOcean Container Registry. If you set the DigitalOcean Container Registry as default registry, note that you do not have to specify the Registry.
Add the following line to your build step:
This is an example of the complete build step:
Note that Codefresh builds AND pushes images both in the same step.
Running the pipeline and viewing the image in the DigitalOcean Container Registry
Once you have modified the step, save and run your pipeline. Below is an example of the pipeline in it’s simplest form.
You can then view the image in the DigitalOcean Container Registry: