Search code examples
artifactory

Practical Use of Artifactory Repositories


In a near future I will start using Artifactory in my project. I have been reading about local and remote repositories and I am a bit confused of their practical use. In general as far as I understand

  • Local repositories are for pushing and pulling artifacts. They have no connection to a remote repository (i.e. npm repo at https://www.npmjs.com/)
  • Remote repositories are for pulling and caching artifacts on demand. It works only one way, it is not possible to push artifacts.

If I am right up to this point, then practically it means you only need a remote repository for npm if you do not develop npm modules but only use them to build your application. In contrast, if you need to both pull and push Docker container images, you need to have one local repository for pushing&pulling custom images and one remote repository for pulling official images.

Question #1

I am confused because our Artifactory admin created a local npm repository for our project. When I discussed the topic with him he told me that I need to first get packages from the internet to my PC and push them to Artifactory server. This does not make any sense to me because I have seen some remote repositories on the same server and what we need is only to pull packages from npm. Is there a point that I miss?

Question #2

Are artifacts at remote repository cache saved until intentionally deleted? Is there a default retention policy (i.e. delete packages older than 6 months)? I ask this because it is important to keep packages until a meteor hits the servers (for archiving policy of the company).

Question #3

We will need to get official Docker images and customize them for CI. It would be a bit hard to maintain one local repo for pulling&pushing custom images and one remote repo for pulling official images. Let's say I need to pull official Ubuntu latest, modify it, push and finally pull the custom image back. In this case it should be pulled using remote repository, pushed to local repo and pulled again from local repo. Is it possible to use virtual repositories to do this seamlessly as one repo?


Solution

  • Question #1 This does not make any sense to me because I have seen some remote repositories on the same server and what we need is only to pull packages from npm. Is there a point that I miss?

    Generally, you would want to use a remote repository for this. You would then point your client to this remote repository and JFrog Artifactory would grab them from the remote site and cache them locally, as needed.

    In some very secure environments, corporate policies do not even allow this (they may not even be connected to the internet) and instead manually download, vet, and then upload those third-party libraries to a local repository. I don't think that is your case and they may just not understand their intended usages.

    Question #2 Are artifacts at remote repository cache saved until intentionally deleted? Is there a default retention policy?

    They will not be deleted unless you actively configure it to do so.

    For some repo types there are built-in retention mechanisms like the number of snapshots or maximum tags but not for all of them and even in those that have it, they must be actively turned on. Different organizations have different policies for how long artifacts must be maintained. There are a lot of ways to cleanup those old artifacts but ultimately it will depend on your own requirements.

    Question #3 Is it possible to use virtual repositories to do this seamlessly as one repo?

    A virtual repository will let you aggregate your local and remote sites and appear as a single source. So you can do something like:

    docker pull myarturl/docker/someimage:sometag ... docker build ... docker push myarturl/docker/someimage:sometag-my-modified-version docker pull myarturl/docker/someimage:sometag-my-modified-version

    It is also security-aware so if the user only has access to the local stuff and not the remote stuff, they will only be able to access the local stuff even though they are using the virtual repository that contains both of them.

    That said, I don't see why it would be any harder to explicitly use different repositories: docker pull myarturl/docker-remote/someimage:sometag ... docker build ... docker push myarturl/docker-local/someimage:sometag-my-modified-version docker pull myarturl/docker-local/someimage:sometag-my-modified-version

    This also has the added advantage that you know they can only pull your modified version of the image and not the remote (though you can also accomplish that by creating the correct permissions).