diff --git a/docker/Dockerfile.headless b/docker/Dockerfile.headless new file mode 120000 index 00000000..1d1fe94d --- /dev/null +++ b/docker/Dockerfile.headless @@ -0,0 +1 @@ +Dockerfile \ No newline at end of file diff --git a/docker/testing/Makefile b/docker/testing/Makefile new file mode 100644 index 00000000..89e6773c --- /dev/null +++ b/docker/testing/Makefile @@ -0,0 +1,46 @@ +# Local building and testing of the Docker image variants. + +# Defensive settings for make: +# https://tech.davis-hansson.com/p/make/ +SHELL:=bash +.ONESHELL: +.SHELLFLAGS:=-eu -o pipefail -c +.SILENT: +.DELETE_ON_ERROR: +MAKEFLAGS+=--warn-undefined-variables +MAKEFLAGS+=--no-builtin-rules +export PS1?=$$ +# Prefix echoed recipe commands with the recipe line number for debugging: +export PS4?=:$$LINENO+ + +VARIANTS=headless gui ubuntu +ROOT_PREREQS:=$(shell find ../root -type f) + +# Finished with `$(shell)`, echo recipe commands going forward +.SHELLFLAGS+= -x + + +### Top-level targets: + +.PHONY: all +all: build + +.PHONY: build +build: $(VARIANTS:%=./build/ytdl-sub-%.log) + +.PHONY: run +run: build $(VARIANTS:%=./volumes/ytdl-sub-%/) + docker compose up + + +### Real targets: + +# Re-build the local images when changes require it. +./build/ytdl-sub-%.log: ../Dockerfile.% $(ROOT_PREREQS) + mkdir -pv "$(dir $(@))" + docker compose build "$(@:build/ytdl-sub-%.log=ytdl-sub-%)" |& + tee -a "$(@)" + +# Ensure volumes are owned by the developer's normal user: +./volumes/ytdl-sub-%/: + mkdir -pv "$(@)" diff --git a/docker/testing/docker-compose.yml b/docker/testing/docker-compose.yml index f3eacb9d..50bc25f0 100644 --- a/docker/testing/docker-compose.yml +++ b/docker/testing/docker-compose.yml @@ -1,5 +1,8 @@ services: ytdl-sub-gui: + build: + context: "../" + dockerfile: "./Dockerfile.gui" image: "ytdl-sub-gui:local" container_name: "ytdl-sub-gui" environment: @@ -13,9 +16,11 @@ services: ports: - "8443:8443" restart: "unless-stopped" - ytdl-sub: - image: "ytdl-sub:local" - container_name: "ytdl-sub" + ytdl-sub-headless: + build: + context: "../" + image: "ytdl-sub-headless:local" + container_name: "ytdl-sub-headless" environment: PUID: "1000" PGID: "1000" @@ -23,9 +28,12 @@ services: CRON_SCHEDULE: '"*/1 * * * *"' CRON_RUN_ON_START: "true" volumes: - - "./volumes/ytdl-sub/:/config/" + - "./volumes/ytdl-sub-headless/:/config/" restart: "unless-stopped" ytdl-sub-ubuntu: + build: + context: "../" + dockerfile: "./Dockerfile.ubuntu" image: "ytdl-sub-ubuntu:local" container_name: "ytdl-sub-ubuntu" environment: diff --git a/docs/source/guides/development/index.rst b/docs/source/guides/development/index.rst index 392ff042..9183331a 100644 --- a/docs/source/guides/development/index.rst +++ b/docs/source/guides/development/index.rst @@ -64,6 +64,20 @@ If integration tests are failing, ensure... - your local ``ytdl-sub`` dependencies are up-to-date +Docker +------ + +Test changes to the Docker image variants locally: + +.. code-block:: shell + + cd ./docker/testing/ + make -j run + +See ``./docker/testing/docker-compose.yml`` for the Compose services for each image +variant. + + IDE Setup ---------