diff --git a/.env.example b/.env.example index 50e1dbb3a..95d06f8b7 100644 --- a/.env.example +++ b/.env.example @@ -18,8 +18,8 @@ # In-container working directory and bind mount target for the repo checkout. # Override when the host clone lives outside the default GOPATH layout; the -# value is reused for working_dir, the source bind mount, and every PhotoPrism -# path env var so they stay in sync. +# value is reused for the Dockerfile WORKDIR (build arg), working_dir, the +# source bind mount, and every PhotoPrism path env var so they stay in sync. # WORKING_DIR=/go/src/github.com/photoprism/photoprism # Network interfaces to which Traefik and other services bind on the host. diff --git a/Dockerfile b/Dockerfile index 8f70eeb1b..ec6479d6c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,16 +18,19 @@ ENV NPM_CONFIG_IGNORE_SCRIPTS=true # FROM photoprism/develop:bullseye # Debian 11 (Bullseye) # FROM photoprism/develop:buster # Debian 10 (Buster) -# Set default working directory. -WORKDIR "/go/src/github.com/photoprism/photoprism" +# Set default working directory. Override WORKING_DIR (e.g. via compose build +# args populated from .env) to match a custom host-side clone layout; the value +# must stay aligned with compose's working_dir and the source bind mount target. +ARG WORKING_DIR=/go/src/github.com/photoprism/photoprism +WORKDIR "${WORKING_DIR}" # Copy source to image. COPY . . -COPY --chown=root:root /scripts/dist/ /scripts/ +COPY --chown=root:root ./scripts/dist/ /scripts/ # Re-install the dev "mariadb" client config so a custom MARIADB_PORT in .env # is honored even when the base image was built before the port= line was # removed (no-op once the next dated base image picks up the new .my.cnf). -COPY --chown=root:root --chmod=644 .my.cnf /etc/my.cnf +COPY --chown=root:root --chmod=644 ./.my.cnf /etc/my.cnf RUN sudo /scripts/install-yt-dlp.sh diff --git a/compose.intel.yaml b/compose.intel.yaml index 3007dab2d..bf95c530f 100644 --- a/compose.intel.yaml +++ b/compose.intel.yaml @@ -1,7 +1,10 @@ services: ## PhotoPrism (Development Environment for Intel QSV hardware transcoding) photoprism: - build: . + build: + context: . + args: + WORKING_DIR: "${WORKING_DIR:-/go/src/github.com/photoprism/photoprism}" image: photoprism/photoprism:develop depends_on: - mariadb diff --git a/compose.nvidia.yaml b/compose.nvidia.yaml index cb1d2f9c0..1251a14d8 100644 --- a/compose.nvidia.yaml +++ b/compose.nvidia.yaml @@ -1,7 +1,10 @@ services: ## PhotoPrism (Development Environment for Nvidia) photoprism: - build: . + build: + context: . + args: + WORKING_DIR: "${WORKING_DIR:-/go/src/github.com/photoprism/photoprism}" image: photoprism/photoprism:develop runtime: nvidia depends_on: diff --git a/compose.yaml b/compose.yaml index 18772da71..713350975 100644 --- a/compose.yaml +++ b/compose.yaml @@ -4,7 +4,10 @@ services: ## PhotoPrism Build & Test Environment photoprism: - build: . + build: + context: . + args: + WORKING_DIR: "${WORKING_DIR:-/go/src/github.com/photoprism/photoprism}" image: photoprism/photoprism:develop depends_on: - mariadb