Skip to content

feat: option to start a local docker registry #1601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

superewald
Copy link
Contributor

@superewald superewald commented Jul 2, 2025

Adds the --registry option to gitlab-ci-local to run a local docker registry. This is useful if jobs build and push docker images using the CI_REGISTRY variable.

implementation

{gclRegistryPrefix} refers to Utils.gclRegistryPrefixand is set toregistry.gcl.local` currently.

  1. starts a local docker registry prior to executing pipelines using registry:2 image if --registry was specified
    1. creates self-signed ssl certificate using alpine/openssl and cache them in {gclRegistryPrefix}.certs volume
    2. runs detached docker registry container configured to use the self-signed ssl certificate within their own network
  2. configure gitlab-ci-local containers to use the local docker registry (as described in "container context")
  3. after pipeline completed, stops and removes the local registry container (but not the network and volumes to avoid recreating the certificate and caching built images)

container context

Using the --registry flag will apply the following modifications to gitlab-ci-local job containers:

  • mount volume with self-signed certificates ({gclRegistryPrefix}.certs, mounted 2 times to support oci and docker cert paths)
  • change $CI_REGISTRY env var to {gclRegistryPrefix} before expanding variables
  • add $CI_REGISTRY_USER={gclRegistryPrefix}.user and $CI_REGISTRY_PASSWORD={gclRegistryPrefix}.pass env variables
  • attach the {gclRegistryPrefix}.net network for communicating with the local registry

Implements #1600

@superewald superewald marked this pull request as draft July 2, 2025 21:01
@superewald superewald marked this pull request as ready for review July 7, 2025 12:32
"-e", `REGISTRY_HTTP_TLS_KEY=/certs/${this.gclRegistryPrefix}.key`,
"registry",
]);
}
Copy link
Owner

@firecow firecow Jul 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@superewald Without a wait-for-port you risk jobs start pushing to the registry before it is ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants