diff --git a/.env b/.env index a49b1e1..4765694 100644 --- a/.env +++ b/.env @@ -31,6 +31,12 @@ REGISTRY_NAME=isle-builder-registry # A value of '0' means the port on the host is randomly assigned by docker. REGISTRY_PORT=0 +# The port on which the registry UI container will listen. +# Note that this is the port on the host, not the port inside the container. +# The port inside the container is always 80. +# A value of '0' means the port on the host is randomly assigned by docker. +REGISTRY_UI_PORT=0 + # The network created by the docker compose file and referenced by the buildkit # container. BUILDER_NAME=isle-builder @@ -40,3 +46,6 @@ BUILDKIT_TAG=v0.11.1 # The version of the registry to use. REGISTRY_TAG=2.8.1 + +# The version of the registry-ui to use. +REGISTRY_UI_TAG=2.4.1 diff --git a/Makefile b/Makefile index 17194eb..8ba1771 100644 --- a/Makefile +++ b/Makefile @@ -115,10 +115,14 @@ certs/cert.pem certs/privkey.pem &: certs $(CAROOT)/rootCA-key.pem $(CAROOT)/roo .PHONY: start ## Starts the Docker image registry and creates the builder if it does not exist. start: certs/cert.pem certs/privkey.pem certs/rootCA.pem | docker-buildx docker-compose - # Start the registry. - @docker compose up -d + # Start the registry if not already started. + @if ! docker inspect $(REGISTRY_NAME) &>/dev/null; then \ + docker compose up -d registry; \ + fi + # Get auto assigned port for registry or explicit one and start the ui as well. + @REGISTRY_PORT=$$(docker inspect --format='{{(index (index .NetworkSettings.Ports "443/tcp") 0).HostPort}}' $(REGISTRY_NAME)) docker compose up -d ui # Create the builder if not already created. - @if ! docker buildx inspect $(BUILDER_NAME) &>/dev/null; \ + @if ! docker buildx inspect --bootstrap $(BUILDER_NAME) &>/dev/null; \ then \ docker buildx create \ --append \ @@ -134,16 +138,25 @@ start: certs/cert.pem certs/privkey.pem certs/rootCA.pem | docker-buildx docker- use: | start docker buildx use $(BUILDER_NAME) +.PHONY: port +## Displays the port the Docker image registry is running on. +port: REGISTRY_PORT=$$(docker inspect --format='{{(index (index .NetworkSettings.Ports "443/tcp") 0).HostPort}}' $(REGISTRY_NAME)) +port: UI_PORT=$$(docker inspect --format='{{(index (index .NetworkSettings.Ports "80/tcp") 0).HostPort}}' $(REGISTRY_NAME)-ui) +port: PORT_MESSAGE = " ${RED}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n" +port: + @printf $(PORT_MESSAGE) "Registry" "https://islandora.io:$(REGISTRY_PORT)" + @printf $(PORT_MESSAGE) "UI" "http://islandora.io:$(UI_PORT)" + .PHONY: stop ## Stops the stops the builder and Docker image registry. stop: | docker-buildx docker-compose # Stop the builder. @if docker buildx inspect $(BUILDER_NAME) &>/dev/null; \ then \ - docker buildx stop $(BUILD_NAME); \ + docker buildx stop $(BUILDER_NAME); \ fi # Stop the registry. - @docker compose down + @docker compose stop .PHONY: prune ## Frees up disk space by pruning the builder cache. diff --git a/README.md b/README.md index 634bee4..48972e9 100644 --- a/README.md +++ b/README.md @@ -7,12 +7,18 @@ - [Introduction](#introduction) - [Requirements](#requirements) - [Usage](#usage) +- [Repository](#repository) + - [Ports](#ports) + - [Pushing](#pushing) ## Introduction The repository is for local testing purposes, it makes it easier to setup a [buildkit] builder for use with [buildx], capable of multi-platform builds. +It also setups up an local [Docker registry] at `islandora.io` which you can be +used to test generating manifests, registry caching etc. + The repository can be used by [isle-buildkit], [isle-site-template], [sandbox], and others. @@ -40,20 +46,70 @@ ARGS: NETWORK_NAME The name of the network. (e.g. isle-builder) REGISTRY_NAME The name of the registry container. (e.g. isle-builder-registry) REGISTRY_PORT The port to expose for registry access. Access via HTTPS. (e.g. 0, which will randomly assigned an open port) + REGISTRY_UI_PORT The port to expose for registry UI. Access via HTTP. (e.g. 0, which will randomly assigned an open port) BUILDER_KEEP_STORAGE When pruning the amount of storage to keep. Set to '0' to remove all. (e.g. 10G) TARGETS: start Starts the Docker image registry and creates the builder if it does not exist. use Switches the default builder to use the one created by the 'start' target. + port Displays the port the Docker image registry is running on. stop Stops the stops the builder and Docker image registry. prune Frees up disk space by pruning the builder cache. destroy Destroys the builder and Docker image registry. help Displays this help message. ``` +## Repository + +### Ports + +By default no ports are specified so they are allocated dynamically. Though you +can choose a port to have it always be consistent (see [Usage](#usage)). + +Regardless, you use the following command to print the URLs at which you can +access the registry REST API and a web based UI. + +```bash +$ make port + Registry https://islandora.io:59963 + UI http://islandora.io:32805 +``` + +### Pushing + +This makes use of as the URL for the local Docker image +repository. It is setup to redirect all requests to `localhost`. + +Assuming you have use the following command to set the default builder to the +one created by this repository: + +```bash +make use +``` + +To push to this local repository you must use the name as the image tag like so: + +```bash +docker buildx build \ + --push \ + --platform linux/arm64,linux/amd64 \ + --tag islandora.io/some-image:latest . +``` + +Or if using a `bake` you should check which variable to override (typically +`REPOSITORY`): + +```bash +REPOSITORY=islandora.io docker buildx bake --push . +``` + +Note that this can be used with `docker-compose.yml` and `docker-bake.hcl` +files. + [buildkit]: https://docs.docker.com/build/buildkit [buildx]: https://docs.docker.com/engine/reference/commandline/buildx [docker compose]: https://docs.docker.com/compose/reference +[Docker registry]: https://docs.docker.com/registry/ [isle-buildkit]: https://github.com/Islandora-Devops/isle-buildkit [isle-site-template]: https://github.com/Islandora-Devops/isle-site-template [official documentation]: https://islandora.github.io/documentation diff --git a/docker-compose.yml b/docker-compose.yml index 490dcce..af5411f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,3 +33,18 @@ services: networks: default: aliases: [ "islandora.io" ] + ui: + image: joxit/docker-registry-ui:${REGISTRY_UI_TAG} + container_name: ${REGISTRY_NAME}-ui + ports: + - "${REGISTRY_UI_PORT}:80" + environment: + - REGISTRY_TITLE=${REGISTRY_NAME} + - PULL_URL=islandora.io:${REGISTRY_PORT} + - DELETE_IMAGES=true + - SHOW_CATALOG_NB_TAGS=true + - SHOW_CONTENT_DIGEST=true + - NGINX_PROXY_PASS_URL=https://islandora.io + - SINGLE_REGISTRY=true + depends_on: + - registry