feat: Integrate container registry support and Makefile enhancements

This commit integrates support for pushing and pulling Docker images from a container registry and enhances the Makefile for a more flexible development workflow.

Key changes include:

- **Container Registry Configuration:** Added  and  variables to the Makefile and updated  and  targets to correctly tag and push images to the configured registry.
- **Docker Compose Registry Integration:** Modified  to use the image from the registry by default instead of building locally.
- **Makefile Workflow Enhancements:**
    - Introduced a  target (Pulling image git.wlkns.org/stephan/audio-engine-hub:latest from registry...
docker pull git.wlkns.org/stephan/audio-engine-hub:latest) for explicitly downloading images from the registry.
    - Modified the  target (Starting development environment by pulling image from registry...
export IMAGE_NAME=audio-engine-hub && \
export REGISTRY=git.wlkns.org && \
export USERNAME=stephan && \
export TAG=latest && \
docker compose up -d) to use the registry image.
    - Added a  target (Starting development environment (local build) on port 8000...) for local development, which explicitly builds the image from source () before starting the service.
    - Updated  and GNU bash, Version 5.1.16(1)-release (x86_64-pc-linux-gnu)
Diese Shellkommandos sind intern definiert. Geben Sie »help« ein, um diese
Liste zu sehen. Geben Sie »help Name« ein, um die Beschreibung der Funktion
»Name« zu sehen. Geben Sie »info bash« ein, um die vollständige Dokumentation
zu sehen. Geben Sie »man -k« oder »info« ein, um detaillierte Beschreibungen
der Shellkommandos zu sehen.

Ein Stern (*) neben dem Namen kennzeichnet deaktivierte Kommandos.

 Jobbezeichnung [&]                                                         history [-c] [-d Offset] [n] oder history -anrw [Dateiname] oder histor>
 (( Ausdruck ))                                                             if Kommandos; then Kommandos; [ elif Kommandos; then Kommandos; ]... [ >
 . Dateiname [Argumente]                                                    jobs [-lnprs] [Jobbezeichnung ...] or jobs -x Kommando [Arg]
 :                                                                          kill [-s Signalname | -n Signalnummer | -Signalname] pid | jobspec ... >
 [ Argument... ]                                                            let Argument [Argument ...]
 [[ Ausdruck ]]                                                             local [Option] Name[=Wert] ...
 alias [-p] [Name[=Wert] ... ]                                              logout [n]
 bg [Jobbezeichnung ...]                                                    mapfile [-d Begrenzer] [-n Anzahl] [-O Quelle] [-s Anzahl] [-t] [-u fd]>
 bind [-lpsvPSVX] [-m Tastaturtabelle] [-f Dateiname] [-q Name] [-u Name]>  popd [-n] [+N | -N]
 break [n]                                                                  printf [-v var] Format [Argumente]
 builtin [Shell-Kommando [Argument ...]]                                    pushd [-n] [+N | -N | Verzeichnis]
 caller [Ausdruck]                                                          pwd [-LP]
 case Wort in [Muster [| Muster]...) Kommandos ;;]... esac                  read [-ers] [-a Feld] [-d Begrenzer] [-i Text] [-n Zeichenanzahl] [-N Z>
 cd [-L|[-P [-e]] [-@]] [Verzeichnis]                                       readarray [-d Begrenzer] [-n Anzahl] [-O Quelle] [-s Anzahl] [-t]      >
 command [-pVv] Kommando [Argument ...]                                     readonly [-aAf] [Name[=Wert] ...] oder readonly -p
 compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlis>  return [n]
 complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpa>  select Name [in Wortliste ... ;] do Kommandos; done
 compopt [-o|+o Option] [-DEI] [Name ...]                                   set [-abefhkmnptuvxBCHP] [-o Option] [--] [Argument ...]
 continue [n]                                                               shift [n]
 coproc [Name] Kommando [Umleitungen]                                       shopt [-pqsu] [-o] [Optionsname ...]
 declare [-aAfFgiIlnrtux] [-p] [Name[=Wert] …]                              source Dateiname [Argumente]
 dirs [-clpv] [+N] [-N]                                                     suspend [-f]
 disown [-h] [-ar] [Jobbezeichnung ... | pid ...]                           test [Ausdruck]
 echo [-neE] [Argument ...]                                                 time [-p] Pipeline
 enable [-a] [-dnps] [-f Dateiname] [Name ...]                              times
 eval [Argument ...]                                                        trap [-lp] [[Argument] Signalbezeichnung ...]
 exec [-cl] [-a Name] [Befehl [Argument …]] [Umleitung …]                   true
 exit [n]                                                                   type [-afptP] Name [Name ...]
 export [-fn] [Name[=Wert] ...] oder export -p                              typeset [-aAfFgiIlnrtux] [-p] Name[=Wert] …
 false                                                                      ulimit [-SHabcdefiklmnpqrstuvxPT] [Grenze]
 fc [-e Editor] [-lnr] [Anfang] [Ende] oder fc -s [Muster=Ersetzung] [Kom>  umask [-p] [-S] [Modus]
 fg [Jobbezeichnung]                                                        unalias [-a] Name [Name ...]
 for Name [in Wortliste ... ] ; do Kommandos; done                          unset [-f] [-v] [-n] [NAME ...]
 for (( Ausdruck1; Ausdruck2; Ausdruck3 )); do Kommandos; done              until Kommandos; do Kommandos; done
 function Name { Kommandos ; } oder Name () { Kommandos ; }                 variables - Namen und Bedeutung einiger Shell-Variablen
 getopts optstring name [arg ...]                                           wait [-fn] [-p var] [id ...]
 hash [-lr] [-p Pfadname] [-dt] [Name ...]                                  while Kommandos; do Kommandos; done
 help [-dms] [Muster ...]                                                   { Kommandos ; } targets accordingly.
- **Session Resume Update:** Updated  to document the container registry integration.
This commit is contained in:
2025-12-04 22:42:38 +01:00
parent a466d8e00f
commit 527f611061
3 changed files with 57 additions and 15 deletions

View File

@ -3,11 +3,10 @@ SHELL := /bin/bash
# --- Configuration --- # --- Configuration ---
IMAGE_NAME := audio-engine-hub IMAGE_NAME := audio-engine-hub
TAG := latest TAG := latest
# Default internal application port (exposed to Traefik) REGISTRY := git.wlkns.org
USERNAME := stephan
# Default internal application port
PORT := 8000 PORT := 8000
# Traefik's external entrypoints
TRAEFIK_WEB_PORT := 80
TRAEFIK_DASHBOARD_PORT := 8080
# --- Port Checking Functions --- # --- Port Checking Functions ---
@ -67,27 +66,48 @@ shell:
.PHONY: up .PHONY: up
up: up:
@echo "Starting development environment by pulling image from registry..."
export IMAGE_NAME=$(IMAGE_NAME) && \
export REGISTRY=$(REGISTRY) && \
export USERNAME=$(USERNAME) && \
export TAG=$(TAG) && \
docker compose up -d
.PHONY: dev-up
dev-up:
@APP_PORT=$$(bash -c 'port=$${PORT:-8000}; while ss -tulnp | grep -q :$$port; do echo "Port $$port is busy. Checking next..." >&2; ((port++)); done; echo $$port'); \ @APP_PORT=$$(bash -c 'port=$${PORT:-8000}; while ss -tulnp | grep -q :$$port; do echo "Port $$port is busy. Checking next..." >&2; ((port++)); done; echo $$port'); \
echo "Starting development environment on port $$APP_PORT..."; \ echo "Starting development environment (local build) on port $$APP_PORT..."; \
export IMAGE_NAME=$(IMAGE_NAME); \ export IMAGE_NAME=$(IMAGE_NAME) && \
export REGISTRY=$(REGISTRY) && \
export USERNAME=$(USERNAME) && \
export TAG=$(TAG) && \
APP_PORT=$$APP_PORT docker compose up --build -d APP_PORT=$$APP_PORT docker compose up --build -d
.PHONY: down .PHONY: down
down: down:
@echo "Stopping development environment with Docker Compose..." @echo "Stopping development environment with Docker Compose..."
export IMAGE_NAME=$(IMAGE_NAME) && docker compose down export IMAGE_NAME=$(IMAGE_NAME) && \
export REGISTRY=$(REGISTRY) && \
export USERNAME=$(USERNAME) && \
export TAG=$(TAG) && \
docker compose down
# --- Image Management --- # --- Image Management ---
.PHONY: pull
pull:
@echo "Pulling image $(REGISTRY)/$(USERNAME)/$(IMAGE_NAME):$(TAG) from registry..."
docker pull $(REGISTRY)/$(USERNAME)/$(IMAGE_NAME):$(TAG)
.PHONY: tag .PHONY: tag
tag: tag:
@echo "Tagging image $(IMAGE_NAME):$(TAG) as $(REGISTRY)/$(IMAGE_NAME):$(TAG)" @echo "Tagging image $(IMAGE_NAME):$(TAG) as $(REGISTRY)/$(USERNAME)/$(IMAGE_NAME):$(TAG)"
docker tag $(IMAGE_NAME):$(TAG) $(REGISTRY)/$(IMAGE_NAME):$(TAG) docker tag $(IMAGE_NAME):$(TAG) $(REGISTRY)/$(USERNAME)/$(IMAGE_NAME):$(TAG)
.PHONY: push .PHONY: push
push: tag push: build tag
@echo "Pushing image $(REGISTRY)/$(IMAGE_NAME):$(TAG) to registry..." @echo "Pushing image $(REGISTRY)/$(USERNAME)/$(IMAGE_NAME):$(TAG) to registry..."
docker push $(REGISTRY)/$(IMAGE_NAME):$(TAG) docker push $(REGISTRY)/$(USERNAME)/$(IMAGE_NAME):$(TAG)
.PHONY: test .PHONY: test
test: test:
@ -133,8 +153,10 @@ help:
@echo " stop - Stop and remove the Docker container" @echo " stop - Stop and remove the Docker container"
@echo " logs - Follow the logs of the container" @echo " logs - Follow the logs of the container"
@echo " shell - Get a shell inside the running container" @echo " shell - Get a shell inside the running container"
@echo " up - Start the dev environment with docker-compose" @echo " up - Start the dev environment by pulling image from registry"
@echo " dev-up - Start the dev environment by building image locally"
@echo " down - Stop the dev environment with docker-compose" @echo " down - Stop the dev environment with docker-compose"
@echo " pull - Pull the Docker image from the registry"
@echo " tag - Tag the image for a registry" @echo " tag - Tag the image for a registry"
@echo " push - Push the image to a registry (after tagging)" @echo " push - Push the image to a registry (after tagging)"
@echo " test - Run the pytest test suite" @echo " test - Run the pytest test suite"

View File

@ -2,7 +2,7 @@ version: '3.8'
services: services:
app: app:
build: . image: ${REGISTRY}/${USERNAME}/${IMAGE_NAME}:${TAG}
container_name: ${IMAGE_NAME}_app container_name: ${IMAGE_NAME}_app
restart: unless-stopped restart: unless-stopped
volumes: volumes:

View File

@ -116,3 +116,23 @@ After the major refactoring, the service was unable to start and was returning `
* A note was added to `docs/guide.md` to clarify that it describes an older, more advanced setup and to point readers to the new `README.md`. * A note was added to `docs/guide.md` to clarify that it describes an older, more advanced setup and to point readers to the new `README.md`.
**Final Status:** The service is now fully deployable via `make up` and passes `make health-check`. All identified startup issues and bugs have been resolved. **Final Status:** The service is now fully deployable via `make up` and passes `make health-check`. All identified startup issues and bugs have been resolved.
### Container Registry Integration
To facilitate pushing and pulling Docker images from a remote registry (e.g., `git.wlkns.org`), the `Makefile` and `docker-compose.yml` were updated:
1. **Makefile Configuration:**
* Added `REGISTRY := git.wlkns.org` and `USERNAME := stephan` variables.
* Modified the `tag` target to tag images in the format `$(REGISTRY)/$(USERNAME)/$(IMAGE_NAME):$(TAG)`.
* Modified the `push` target to depend on `build` and `tag`, then push the image to the configured registry.
2. **`docker-compose.yml` Integration:**
* Changed the `app` service definition to use `image: ${REGISTRY}/${USERNAME}/${IMAGE_NAME}:${TAG}` instead of `build: .`, making it pull from the registry by default.
3. **Makefile Workflow Enhancements:**
* Added a `pull` target (`make pull`) to explicitly download the image from the registry.
* The `up` target (`make up`) was modified to start the service using the image specified in `docker-compose.yml` (which now points to the registry).
* A new `dev-up` target (`make dev-up`) was introduced for local development, which explicitly builds the image from source (`docker compose up --build -d`) before starting the service.
* The `down` and `help` targets were updated accordingly.
This allows for flexible deployment, supporting both local development with on-demand building and production-like environments pulling from a registry.