fix(docker): Default config available in WORKDIR (#1303)

Adds better support to run commands via `docker exec ...` by setting the working directory to be ytdl-sub's working directory.

Thanks @rpatterson for the contribution 😊
This commit is contained in:
Ross Patterson 2025-08-27 20:17:57 -07:00 committed by GitHub
parent d1e584d505
commit 283ccc8608
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 123 additions and 48 deletions

View file

@ -7,9 +7,11 @@ FROM ghcr.io/linuxserver/baseimage-alpine:edge
ENV OPENSSL_CONF="/etc/ssl" ENV OPENSSL_CONF="/etc/ssl"
# For downloading thumbnails # For downloading thumbnails
ENV SSL_CERT_DIR="/etc/ssl/certs/" ENV SSL_CERT_DIR="/etc/ssl/certs/"
# Working directory used at both build and run times:
ENV DEFAULT_WORKSPACE="/config"
COPY root/ / COPY root/ /
RUN mkdir -p /config && \ RUN mkdir -pv "${DEFAULT_WORKSPACE}" && \
apk update --no-cache && \ apk update --no-cache && \
apk upgrade --no-cache && \ apk upgrade --no-cache && \
apk add --no-cache --repository=http://dl-3.alpinelinux.org/alpine/edge/main/ \ apk add --no-cache --repository=http://dl-3.alpinelinux.org/alpine/edge/main/ \
@ -58,12 +60,12 @@ RUN mkdir -p /config && \
# CONTAINER CONFIGS # CONTAINER CONFIGS
ENV EDITOR="nano" \ ENV EDITOR="nano" \
HOME="/config" \ HOME="${DEFAULT_WORKSPACE}" \
DOCKER_MODS=linuxserver/mods:universal-stdout-logs|linuxserver/mods:universal-cron \ DOCKER_MODS=linuxserver/mods:universal-stdout-logs|linuxserver/mods:universal-cron \
DEFAULT_WORKSPACE=/config \ CRON_SCRIPT="${DEFAULT_WORKSPACE}/cron" \
CRON_SCRIPT="/config/cron" \ CRON_WRAPPER_SCRIPT="${DEFAULT_WORKSPACE}/.cron_wrapper" \
CRON_WRAPPER_SCRIPT="/config/.cron_wrapper" \ LOGS_TO_STDOUT="${DEFAULT_WORKSPACE}/.cron.log" \
LOGS_TO_STDOUT=/config/.cron.log \
LSIO_FIRST_PARTY=false LSIO_FIRST_PARTY=false
VOLUME /config VOLUME "${DEFAULT_WORKSPACE}"
WORKDIR "${DEFAULT_WORKSPACE}"

View file

@ -81,9 +81,10 @@ ENV EDITOR="nano" \
HOME="/config" \ HOME="/config" \
DOCKER_MODS=linuxserver/mods:universal-stdout-logs|linuxserver/mods:universal-cron \ DOCKER_MODS=linuxserver/mods:universal-stdout-logs|linuxserver/mods:universal-cron \
DEFAULT_WORKSPACE=/config/ytdl-sub-configs \ DEFAULT_WORKSPACE=/config/ytdl-sub-configs \
CRON_SCRIPT="/config/ytdl-sub-configs/cron" \ CRON_SCRIPT="${DEFAULT_WORKSPACE}/cron" \
CRON_WRAPPER_SCRIPT="/config/.cron_wrapper" \ CRON_WRAPPER_SCRIPT="/config/.cron_wrapper" \
LOGS_TO_STDOUT=/config/.cron.log \ LOGS_TO_STDOUT=/config/.cron.log \
LSIO_FIRST_PARTY=false LSIO_FIRST_PARTY=false
VOLUME /config VOLUME /config
WORKDIR "${DEFAULT_WORKSPACE}"

1
docker/Dockerfile.headless Symbolic link
View file

@ -0,0 +1 @@
Dockerfile

View file

@ -7,13 +7,15 @@ ARG DEBIAN_FRONTEND=noninteractive
ENV OPENSSL_CONF="/etc/ssl" ENV OPENSSL_CONF="/etc/ssl"
# For downloading thumbnails # For downloading thumbnails
ENV SSL_CERT_DIR="/etc/ssl/certs/" ENV SSL_CERT_DIR="/etc/ssl/certs/"
# Working directory used at both build and run times:
ENV DEFAULT_WORKSPACE="/config"
############################################################################### ###############################################################################
# YTDL-SUB INSTALL # YTDL-SUB INSTALL
SHELL ["/bin/bash", "-c"] SHELL ["/bin/bash", "-c"]
COPY root/ / COPY root/ /
RUN mkdir -p /config && \ RUN mkdir -pv "${DEFAULT_WORKSPACE}" && \
apt-get -y update && \ apt-get -y update && \
apt-get -y upgrade && \ apt-get -y upgrade && \
apt-get install --no-install-recommends -y \ apt-get install --no-install-recommends -y \
@ -81,12 +83,12 @@ RUN mkdir -p /config && \
# CONTAINER CONFIGS # CONTAINER CONFIGS
ENV EDITOR="nano" \ ENV EDITOR="nano" \
HOME="/config" \ HOME="${DEFAULT_WORKSPACE}" \
DOCKER_MODS=linuxserver/mods:universal-stdout-logs|linuxserver/mods:universal-cron \ DOCKER_MODS=linuxserver/mods:universal-stdout-logs|linuxserver/mods:universal-cron \
DEFAULT_WORKSPACE=/config \ CRON_SCRIPT="${DEFAULT_WORKSPACE}/cron" \
CRON_SCRIPT="/config/cron" \ CRON_WRAPPER_SCRIPT="${DEFAULT_WORKSPACE}/.cron_wrapper" \
CRON_WRAPPER_SCRIPT="/config/.cron_wrapper" \ LOGS_TO_STDOUT="${DEFAULT_WORKSPACE}/.cron.log" \
LOGS_TO_STDOUT=/config/.cron.log \
LSIO_FIRST_PARTY=false LSIO_FIRST_PARTY=false
VOLUME /config VOLUME "${DEFAULT_WORKSPACE}"
WORKDIR "${DEFAULT_WORKSPACE}"

46
docker/testing/Makefile Normal file
View file

@ -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 "$(@)"

View file

@ -1,39 +1,47 @@
services: services:
ytdl-sub-gui: ytdl-sub-gui:
image: ytdl-sub-gui:local build:
container_name: ytdl-sub-gui context: "../"
dockerfile: "./Dockerfile.gui"
image: "ytdl-sub-gui:local"
container_name: "ytdl-sub-gui"
environment: environment:
- PUID=1000 PUID: "1000"
- PGID=1000 PGID: "1000"
- TZ=America/Los_Angeles TZ: "America/Los_Angeles"
- CRON_SCHEDULE="*/1 * * * *" CRON_SCHEDULE: '"*/1 * * * *"'
- CRON_RUN_ON_START=true CRON_RUN_ON_START: "true"
volumes: volumes:
- ./volumes/ytdl-sub-gui:/config - "./volumes/ytdl-sub-gui/:/config/"
ports: ports:
- 8443:8443 - "8443:8443"
restart: unless-stopped restart: "unless-stopped"
ytdl-sub: ytdl-sub-headless:
image: ytdl-sub:local build:
container_name: ytdl-sub context: "../"
image: "ytdl-sub-headless:local"
container_name: "ytdl-sub-headless"
environment: environment:
- PUID=1000 PUID: "1000"
- PGID=1000 PGID: "1000"
- TZ=America/Los_Angeles TZ: "America/Los_Angeles"
- CRON_SCHEDULE="*/1 * * * *" CRON_SCHEDULE: '"*/1 * * * *"'
- CRON_RUN_ON_START=true CRON_RUN_ON_START: "true"
volumes: volumes:
- ./volumes/ytdl-sub:/config - "./volumes/ytdl-sub-headless/:/config/"
restart: unless-stopped restart: "unless-stopped"
ytdl-sub-ubuntu: ytdl-sub-ubuntu:
image: ytdl-sub-ubuntu:local build:
container_name: ytdl-sub-ubuntu context: "../"
dockerfile: "./Dockerfile.ubuntu"
image: "ytdl-sub-ubuntu:local"
container_name: "ytdl-sub-ubuntu"
environment: environment:
- PUID=1000 PUID: "1000"
- PGID=1000 PGID: "1000"
- TZ=America/Los_Angeles TZ: "America/Los_Angeles"
- CRON_SCHEDULE="*/1 * * * *" CRON_SCHEDULE: '"*/1 * * * *"'
- CRON_RUN_ON_START=true CRON_RUN_ON_START: "true"
volumes: volumes:
- ./volumes/ytdl-sub:/config - "./volumes/ytdl-sub-ubuntu/:/config/"
restart: unless-stopped restart: "unless-stopped"

View file

@ -52,9 +52,10 @@ above command will rebuild those as well.
Testing Testing
------- -------
Tests are written using pytest. Many of them evaluate checksums of output files to ensure no unintended
changes are introduced to the way ``ytdl-sub`` produces files. This checksum can be inaccurate for Tests are written using pytest. Many of them evaluate checksums of output files to
end-to-end tests, but are reliable for integration tests. ensure no unintended changes are introduced to the way ``ytdl-sub`` produces files. This
checksum can be inaccurate for end-to-end tests, but are reliable for integration tests.
If integration tests are failing, ensure... If integration tests are failing, ensure...
@ -63,6 +64,20 @@ If integration tests are failing, ensure...
- your local ``ytdl-sub`` dependencies are up-to-date - 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 IDE Setup
--------- ---------