Syncing Gitlab Container registry to Artifactory
So! In short i've had some weird issues setting up sync from Gitlab via AF, so i opted for a "manual" approach leveraging Skopeo.
Skopeo is a facinating tool that allows you to manipulate container images in quite a few different ways without even needing a container runtime.
https://github.com/containers/skopeo
To be precise i use the Skopeo Sync command
https://github.com/containers/skopeo/blob/main/docs/skopeo-sync.1.md
The sync command allows you to define the source as a yaml config. In said yaml config you can select multiple sources and which tags to want with for example a regex.
Like so:
# Syncs all helper images from gitlab marked with version number
registry.gitlab.com:
images-by-tag-regex:
gitlab-org/gitlab-runner/gitlab-runner-helper: ^x86_64-v([0-9]{1,2})(\.([0-9]{1,2}))?(\.([0-9]{1,2}))?$
gitlab-org/release-cli: ^v([0-9]{1,2})(\.([0-9]{1,2}))?(\.([0-9]{1,2}))?$
gitlab-org/security-products/analyzers/container-scanning: ^([0-9]{1,2})(\.([0-9]{1,2}))?(\.([0-9]{1,2}))?$
gitlab-org/security-products/analyzers/brakeman : ^([0-9]{1,2})(\.([0-9]{1,2}))?(\.([0-9]{1,2}))?$
gitlab-org/security-products/analyzers/flawfinder : ^([0-9]{1,2})(\.([0-9]{1,2}))?(\.([0-9]{1,2}))?$
gitlab-org/security-products/analyzers/kubesec : ^([0-9]{1,2})(\.([0-9]{1,2}))?(\.([0-9]{1,2}))?$
gitlab-org/security-products/analyzers/mobsf : ^([0-9]{1,2})(\.([0-9]{1,2}))?(\.([0-9]{1,2}))?$
gitlab-org/security-products/analyzers/nodejs-scan : ^([0-9]{1,2})(\.([0-9]{1,2}))?(\.([0-9]{1,2}))?$
gitlab-org/security-products/analyzers/phpcs-security-audit : ^([0-9]{1,2})(\.([0-9]{1,2}))?(\.([0-9]{1,2}))?$
gitlab-org/security-products/analyzers/pmd-apex : ^([0-9]{1,2})(\.([0-9]{1,2}))?(\.([0-9]{1,2}))?$
gitlab-org/security-products/analyzers/semgrep : ^([0-9]{1,2})(\.([0-9]{1,2}))?(\.([0-9]{1,2}))?$
gitlab-org/security-products/analyzers/sobelow : ^([0-9]{1,2})(\.([0-9]{1,2}))?(\.([0-9]{1,2}))?$
gitlab-org/security-products/analyzers/spotbugs : ^([0-9]{1,2})(\.([0-9]{1,2}))?(\.([0-9]{1,2}))?$
#tls-verify: false
Combining this with a quick command like so and we will get all the containers to our registry <3
skopeo sync --src yaml --dest docker sync-gitlab.yaml "$CONTAINER_REGISTRY_URL"