Skip to content

Commit

Permalink
Added UI and improved documentation, fixed problem with make stop.
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelgbanks committed Apr 18, 2023
1 parent a009033 commit 945ee67
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 5 deletions.
9 changes: 9 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
23 changes: 18 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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.
Expand Down
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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 <https://islandora.io> 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
Expand Down
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 945ee67

Please sign in to comment.