diff --git a/Makefile b/Makefile index 8505462..4ab7ceb 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,10 @@ SHELL := /bin/bash # --- Configuration --- IMAGE_NAME := audio-engine-hub TAG := latest -# Default internal application port (exposed to Traefik) +REGISTRY := git.wlkns.org +USERNAME := stephan +# Default internal application port PORT := 8000 -# Traefik's external entrypoints -TRAEFIK_WEB_PORT := 80 -TRAEFIK_DASHBOARD_PORT := 8080 # --- Port Checking Functions --- @@ -67,27 +66,48 @@ shell: .PHONY: 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'); \ - echo "Starting development environment on port $$APP_PORT..."; \ - export IMAGE_NAME=$(IMAGE_NAME); \ + echo "Starting development environment (local build) on port $$APP_PORT..."; \ + export IMAGE_NAME=$(IMAGE_NAME) && \ + export REGISTRY=$(REGISTRY) && \ + export USERNAME=$(USERNAME) && \ + export TAG=$(TAG) && \ APP_PORT=$$APP_PORT docker compose up --build -d .PHONY: down down: @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 --- +.PHONY: pull +pull: + @echo "Pulling image $(REGISTRY)/$(USERNAME)/$(IMAGE_NAME):$(TAG) from registry..." + docker pull $(REGISTRY)/$(USERNAME)/$(IMAGE_NAME):$(TAG) + .PHONY: tag tag: - @echo "Tagging image $(IMAGE_NAME):$(TAG) as $(REGISTRY)/$(IMAGE_NAME):$(TAG)" - docker tag $(IMAGE_NAME):$(TAG) $(REGISTRY)/$(IMAGE_NAME):$(TAG) + @echo "Tagging image $(IMAGE_NAME):$(TAG) as $(REGISTRY)/$(USERNAME)/$(IMAGE_NAME):$(TAG)" + docker tag $(IMAGE_NAME):$(TAG) $(REGISTRY)/$(USERNAME)/$(IMAGE_NAME):$(TAG) .PHONY: push -push: tag - @echo "Pushing image $(REGISTRY)/$(IMAGE_NAME):$(TAG) to registry..." - docker push $(REGISTRY)/$(IMAGE_NAME):$(TAG) +push: build tag + @echo "Pushing image $(REGISTRY)/$(USERNAME)/$(IMAGE_NAME):$(TAG) to registry..." + docker push $(REGISTRY)/$(USERNAME)/$(IMAGE_NAME):$(TAG) .PHONY: test test: @@ -133,8 +153,10 @@ help: @echo " stop - Stop and remove the Docker container" @echo " logs - Follow the logs of the 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 " pull - Pull the Docker image from the registry" @echo " tag - Tag the image for a registry" @echo " push - Push the image to a registry (after tagging)" @echo " test - Run the pytest test suite" diff --git a/docker-compose.yml b/docker-compose.yml index 5566d51..120f82d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '3.8' services: app: - build: . + image: ${REGISTRY}/${USERNAME}/${IMAGE_NAME}:${TAG} container_name: ${IMAGE_NAME}_app restart: unless-stopped volumes: diff --git a/session_resumee.md b/session_resumee.md index a855681..5a09ca3 100644 --- a/session_resumee.md +++ b/session_resumee.md @@ -115,4 +115,24 @@ After the major refactoring, the service was unable to start and was returning ` * The `README.md` was completely rewritten to provide a clear and up-to-date guide for getting started, usage, and available `make` commands. * 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. \ No newline at end of file +**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.