Automating CI/CD for Docker With Oracle Cloud Infrastructure Registry and Developer Cloud Service
Learn how to set up an automated CI/CD chain that publishes Docker containers into the Oracle Cloud Infrastructure Registry.
Join the DZone community and get the full member experience.Join For Free
In recent releases, Developer Cloud Service (DevCS) has expanded to allow you to manage the full lifecycle of Infrastructure in addition to software. One area where we made things simpler is in the management of CI/CD for Docker containers.
In this article, I'll take you through the basics of setting up a CI/CD chain that publishes Docker containers into the Oracle Cloud Infrastructure Registry (OCIR), Oracle's cloud-hosted Docker registry. If you need a little tutorial on getting started with OCIR and Docker using command lines, you can use this one.
Here is a demo video showing you how to leverage DevCS to automate the publishing process of Docker images and hook it into the Git repository in DevCS:
A few notes to help you replicate the steps I take in the video:
You will need to configure a DevCS build server that will have the Docker software on it to run your builds. You do this from the "organization" menu under your username (or get your org admin to do this for you). If you need tips, Abhinav shows you how to do it in this blog entry.
In order to work with OCIR from DevCS, you'll need to have an Oracle Compute user created and have an auth token generated for it, make sure you have this token available for you as you'll need it when working from DevCS. (Note that this is separate from the password the user uses to login into the Oracle compute dashboard).
Now that you have a user, it's time to start your DevCS work. The first thing you might want to do is upload the code for a Docker image into your DevCS git repository. In the video below you'll see that I'm using a very simple application and that my Docker file is part of the 3 files I upload into the git repository in DevCS. (You'll need some sample code; pick up this Docker getting started tutorial).
Once your code is in DevCS - the next step is to create a build job that pushes your code into the OCI Registry. Our job has three steps that leverage the following Docker commands:
- Login - You'll need to use your tenantName/user as the username and the auth token as the password. Your registry URL will depend on the center you are in iad - Ashburn, phx -Phoenix etc. In my case, it was iad.ocir.io.
- Build - You'll want to specify a complete image name again using your tenant/user/imageName. Also, make sure to indicate where your Docker file is (or provide a Docker file in that step).
- Push - Here everything should already be filled out for you and ready to go.
Here is what the completed job looks like:
Now, run your build and it will build your image, and if it succeeds, it will push it to the registry. Monitor the build's log in case you run into errors.
You can hook up the Docker registry section of DevCS to point to the OCIR registry, and then you'll be able to see all the images you pushed there. Again provide your tenant/user and auth token as the login info to the repository.
Have fun automating your Docker publishing on the Oracle Cloud!
Published at DZone with permission of Shay Shmeltzer, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.