How to setup Conan Repository on Artifactory via Docker
For C++ developers package/library management is not simple as in other many languages. However, there are some tools that make this process less painful. One of those tools is Conan which is a portable package manager, intended for C and C++ developers, but it is able to manage builds from source, dependencies, and precompiled binaries for any language. Conan is free and opensource, works on all mainstream operating systems including Windows, Linux, macOS, FreeBSD, etc.
Nonetheless in this post, I want to go over the platform “Artifactory” from JFrog where you can deploy your Conan packages. Basically, Artifactory is a universal repository manager supports lots of package type such as docker registry, npm, deb packages, and much more. On the contrary, to Conan, the Artifactory is a commercial tool.
Luckily JFrog provides a community version for C/C++ developers where you can deploy your Conan packages without any payment.
Following tools I will use during this post.* Docker
* Artifactory
* Conan
Let’s start to install and setup Artifactory on your machine. Sure you can install on your machine as service but I will use docker without installing. We are living in Cloud/Container time, everything should work in a container as well :)
So will use official documentation of Artifactory and perform described instruction. Moving on step by step:
- Step: Create a home directory and system.yml file for Artifactory.
I manipulate home path different than documentation.
btw : I am using linux debian$ mkdir -p $JFROG_HOME/var/artifactory/etc/cd
$ cd $JFROG_HOME/var/artifactory/etc/
$ touch ./system.yaml
$ chown -R 1030:1030 $JFROG_HOME/artifactory/var
Now we’ve created the Artifactory home directory and gave the required permission for the home path. So let’s run the docker container.
2. Pull the docker image and run the container
$ docker pull docker.bintray.io/jfrog/artifactory-cpp-ce:latest$ docker run — name artifactory \ #container name
-v $JFROG_HOME/var/artifactory/:/var/opt/jfrog/artifactory \ #volume
-d -p 8081:8081 -p 8082:8082 \ #mapping ports
docker.bintray.io/jfrog/artifactory-cpp-ce:latest #image name
After pulling the docker image we ran the container. Browse localhost:8082 on your browser then you should see the following screen:
Or you might see the login page in case the container gets ready fast. The default user and password
admin:password
3. Step: Create repository
Enter the username and password above and the next screen will be resetting admin default password wizard, go simply through the steps. After you change the default password successfully you might create Conan repository now or later.
Hence it’s the community version, you’re able to create either Conan or Generic repository type, but we want to use for Conan packages. Click next then the following screen should appear:
Repository Key * → your custom repo name
Layout →leave as conan default
Public/internal description → optional
Include/Exclude Pattern → To optimizing repo, you might include or exclude certain sources. For more see
Save it then you are ready to use. Before we deploy a simple Conan package to our repo “medium-conan” on Artifactory, it might be useful to see Admin-Panel :
From admin panel, you can set your security parameters, create use for developer to deploy packages or monitoring all repository, etc.
4. Step: Deploy Conan packages:
Now on we are ready to deploy our Conan package. I’ve already created some Conan packages which I will deploy to Artifactory. Some substeps:
4.1. Add repository to your remote repository on your local machine by the following command:
conan remote add <any_name> http://<localhost:Port>/artifactory/api/conan/<repo-name>
#I give name as medium and my docker ip and repo_name
$ conan remote add medium http://172.17.0.2:8082/artifactory/api/conan/medium-conan
If you added successfully then ready to deploy. See my screen:
4.2. conan upload “ ” -> double quotes mean add all available conan package-r=<your-remote-name> -> minus "-r" for your remote name -c -> minus c mean confirm otherwise you have to say "yes"
Then enter the username and password. That’s it!
Let’s move on Artifactory to monitor it:
medium-conan LOCAL Conan 100% 5.77KB 12 16 28
The packages are about 6 KB and consist of 12 files etc.
**** NOTE THAT*****if you run Artifactory on docker localhost will not work you have to give Docker container IP or you should start the container with your host argument. Enter remote URL carefully without any typo etc.