Artifactory is a highly versatile and effective tool that serves as an ideal Docker registry for managing and storing Docker images. With its support for multiple Docker repositories, advanced search functions, and comprehensive access control, Artifactory offers a range of features to simplify Docker registry management. Additionally, Artifactory supports Docker Content Trust, which enables users to sign and verify Docker images to ensure their authenticity and integrity. The tool also integrates seamlessly with popular development tools like Jenkins, Kubernetes, and Helm, making it an excellent solution for containerized application development and deployment. By utilizing Artifactory as a Docker registry, managing Docker images can be streamlined, resulting in improved efficiency and security in the development pipeline.
Docker registry can be used to push our artifacts.You need a CI/CD tool to push your artifacts, files, images, etc, to the Artifactory. In this tutorial, we will see how to create a Docker registry from Artifactory and push our artifacts into it using Harness CI. Harness is a leader in software continuous delivery and has a robust CI module.
Prerequisites
- Free Harness account to push our artifacts
- Free JFrog Artifactory account
- A sample application. Fork this sample Node.js application
Tutorial
Sign in to your Harness account and select the Continuous Integration module.
Start creating your first pipeline
Select the code repository system. Our code is on GitHub and hence we select GitHub from this list
Add the access token from your GitHub and authenticate the GitHub. Make sure the connection is successful.
Select the repo we are working on. Hope you have forked our sample Node.js application repo.
Next, select Node.js from the list as our application is a Node.js application.
Once you select Node.js from the list, you should see a default yaml on the right side. That is the yaml format of your pipeline. Yes, we have an option to edit and work through yaml also.
Click on 'Create Pipeline' and you will land on the pipeline studio that looks like below
When you click on the 'Build Node App' stage, you should see a default step configured already. That is 'Build Node App'.
If you click on that step 'Build Node App', you will see the settings configured for you. You can see what's happening there:) Basically, the npm packages required for the application are getting installed, then the build and test is happening.
Now, let's go back to our main pipeline studio and add a step to add the Artifactory.
Click on 'Add Step' and you will be presented with various options from the step library. Select 'Upload artifact to JFrog Artifactory'.
Do you see that Artifactory connector? We have not connected our Artifactory yet. Let's do it by adding new connector.
Add the connector details, starting with the name.
If you don't have a Artifactory account, create one, it is free.
Sign in and select Docker from the package type.
It is a well-guided document that will guide you through a complete Docker registry setup. Run the commands shown in the guided document in your terminal.
Finally, this is what you can see:)
You need to make a note of your API key, which is your password.
We are done with setting up the Docker registry in Artifactory.
Let's get to our Artifactory connector setup and add the API key as a secret.
Add all the details and continue.
In the connect to provider, select 'Connect through Harness Platform'
Make sure the connection is successful.
We successfully added the Artifactory connector.
Let's go back to the Artifactory step and add other details such as target and source path. Just for this example, we are going to push our package.json file contents to our newly created Docker registry from Artifactory. We have mentioned the same in the source path.
Apply changes, save everything and run the pipeline.
You should see a successful pipeline execution.
In the console view, you can see the last step, i.e Artifactory step.
You can verify if the artifact pushed by going to your Artifactory dashboard. You should see our package.json pushed.
Congratulations! We successfully created a Docker registry from Artifactory and pushed our artifacts (package.json in this case) with the help of Harness.
This way, developers can easily build and push any artifacts by creating their own Docker registry with Artifactory and Harness.
I have also written a tutorial on setting up a CI/CD pipeline from scratch.
Take a look