1
Fork 0
photoview/Dockerfile

114 lines
3.4 KiB
Docker
Raw Normal View History

### Build UI ###
FROM --platform=${BUILDPLATFORM:-linux/amd64} node:18 AS ui
# See for details: https://github.com/hadolint/hadolint/wiki/DL4006
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
2020-03-01 02:06:18 +01:00
2021-07-15 17:43:07 +02:00
ARG REACT_APP_API_ENDPOINT
ENV REACT_APP_API_ENDPOINT=${REACT_APP_API_ENDPOINT}
2020-03-01 02:06:18 +01:00
# Set environment variable UI_PUBLIC_URL from build args, uses "/" as default
ARG UI_PUBLIC_URL
ENV UI_PUBLIC_URL=${UI_PUBLIC_URL:-/}
ARG VERSION
ENV VERSION=${VERSION:-undefined}
2021-08-30 12:22:12 +02:00
ENV REACT_APP_BUILD_VERSION=${VERSION:-undefined}
ARG BUILD_DATE
ENV BUILD_DATE=${BUILD_DATE:-undefined}
2021-07-15 17:43:07 +02:00
ENV REACT_APP_BUILD_DATE=${BUILD_DATE:-undefined}
2021-04-20 18:14:52 +02:00
ARG COMMIT_SHA
ENV COMMIT_SHA=${COMMIT_SHA:-}
2021-08-30 12:22:12 +02:00
ENV REACT_APP_BUILD_COMMIT_SHA=${COMMIT_SHA:-}
2021-04-20 18:14:52 +02:00
WORKDIR /app/ui
COPY ui/package.json ui/package-lock.json /app/ui
RUN npm ci
COPY ui/ /app/ui
RUN if [ "${BUILD_DATE}" = "undefined" ]; then \
export BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ'); \
export REACT_APP_BUILD_DATE=${BUILD_DATE}; \
fi; \
npm run build -- --base=$UI_PUBLIC_URL
2020-03-01 02:06:18 +01:00
### Build API ###
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.22-bookworm AS api
ARG TARGETPLATFORM
# See for details: https://github.com/hadolint/hadolint/wiki/DL4006
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
WORKDIR /app/api
Refactor docker deployment and user setup (#863) * Fix #862, address #826 and maybe some other tickets: reimplemented the docker-compose user setup to enhance product setup experience and cover much more cases. * make unique DB container name and use it in communication from Photoview * Removed unnecessary healthcheck for photoview from docker-compose.example.yml, as it is defined in the Dockerfile; optimized Dockerfile combining all RUN directives of PROD stage into 1, which will produce single layer and save some space; added Dockerfile-dev, docker-compose-dev.yml, and new "dev" and "dev-down" directives into Makefile, which allows to setup development env in Docker. Instructions of how to use it are in comments at the beginning of Dockerfile-dev and docker-compose-dev.yml files * Set RWX permissions to the application's working folder for any user, so that the image could be later run with non-root permissions and the app still be able to do needed operations in the FS * Enhanced the "Getting started" section in the readme; added the `help` target and enhanced comments in the Makefile; commented out the `docker system prune -f` with the comment about the command and why it is there; added optional and commented by default `7zz` commands to the `backup` section of the Makefile * Use `slim` base image for final photoview image * Implement SQLite support according to the PR #851 * Removed deprecated `version` line from compose files; optimized dockerfile to build with less layers and run as non-root; mapped only Photoview related services to Watchtower by default instead of updating all running images on a host; added template for Postgres to the .env; reverted compose executable definition, so the new compose is called when present; added a tip about `lnav` to help * fix a typo in the username; add support of PostgreSQL; split and optimize backup target in Makefile * Fixed some typos and styling in Readme, excluded dev-environment setup from the PR; added a list of tips on how to secure Photoview in the Advanced setup section of Readme * Implemented many security improvements, suggested by @Omar007, switched to the dedicated Darktable's repo to install the latest released version, as asked in #935; switched Watchtower to labels instead of profiles * forgot the compose file * move face models back to /app folder; comment out and document unnecessary vars in compose; fix a typo in a few vars * Exclude Makefile in the root folder from git; documented multiple mounts case better; fixed incorrect SQLite DB path * Fixed several bugs after complete testing cycle with all 3 DBs * removed hardcoded port in Dockerfile * Pin the major version for the `photoview` image for stability * Revert back to the port 80 inside the container on product owner's request * Provide a minimal compose file and update the readme accordingly * Handle incorrect media file and folder permissions; set correct permissions for storage folder; fix healthcheck command for postgres --------- Co-authored-by: Konstantin Koval <kkb@ukr.net>
2024-05-15 10:58:02 +02:00
2021-03-31 23:32:37 +02:00
ENV GOPATH="/go"
ENV PATH="${GOPATH}/bin:${PATH}"
ENV CGO_ENABLED=1
2020-08-09 20:32:02 +02:00
# Download dependencies
COPY scripts/apt/debian-testing.sources /etc/apt/sources.list.d/
COPY scripts/set_compiler_env.sh /app/scripts/
COPY scripts/install_build_dependencies.sh /app/scripts/
COPY scripts/install_runtime_dependencies.sh /app/scripts/
RUN chmod +x /app/scripts/*.sh \
&& /app/scripts/install_build_dependencies.sh \
&& /app/scripts/install_runtime_dependencies.sh
COPY api/go.mod api/go.sum /app/api/
RUN source /app/scripts/set_compiler_env.sh \
Refactor docker deployment and user setup (#863) * Fix #862, address #826 and maybe some other tickets: reimplemented the docker-compose user setup to enhance product setup experience and cover much more cases. * make unique DB container name and use it in communication from Photoview * Removed unnecessary healthcheck for photoview from docker-compose.example.yml, as it is defined in the Dockerfile; optimized Dockerfile combining all RUN directives of PROD stage into 1, which will produce single layer and save some space; added Dockerfile-dev, docker-compose-dev.yml, and new "dev" and "dev-down" directives into Makefile, which allows to setup development env in Docker. Instructions of how to use it are in comments at the beginning of Dockerfile-dev and docker-compose-dev.yml files * Set RWX permissions to the application's working folder for any user, so that the image could be later run with non-root permissions and the app still be able to do needed operations in the FS * Enhanced the "Getting started" section in the readme; added the `help` target and enhanced comments in the Makefile; commented out the `docker system prune -f` with the comment about the command and why it is there; added optional and commented by default `7zz` commands to the `backup` section of the Makefile * Use `slim` base image for final photoview image * Implement SQLite support according to the PR #851 * Removed deprecated `version` line from compose files; optimized dockerfile to build with less layers and run as non-root; mapped only Photoview related services to Watchtower by default instead of updating all running images on a host; added template for Postgres to the .env; reverted compose executable definition, so the new compose is called when present; added a tip about `lnav` to help * fix a typo in the username; add support of PostgreSQL; split and optimize backup target in Makefile * Fixed some typos and styling in Readme, excluded dev-environment setup from the PR; added a list of tips on how to secure Photoview in the Advanced setup section of Readme * Implemented many security improvements, suggested by @Omar007, switched to the dedicated Darktable's repo to install the latest released version, as asked in #935; switched Watchtower to labels instead of profiles * forgot the compose file * move face models back to /app folder; comment out and document unnecessary vars in compose; fix a typo in a few vars * Exclude Makefile in the root folder from git; documented multiple mounts case better; fixed incorrect SQLite DB path * Fixed several bugs after complete testing cycle with all 3 DBs * removed hardcoded port in Dockerfile * Pin the major version for the `photoview` image for stability * Revert back to the port 80 inside the container on product owner's request * Provide a minimal compose file and update the readme accordingly * Handle incorrect media file and folder permissions; set correct permissions for storage folder; fix healthcheck command for postgres --------- Co-authored-by: Konstantin Koval <kkb@ukr.net>
2024-05-15 10:58:02 +02:00
&& go env \
&& go mod download \
# Patch go-face
&& sed -i 's/-march=native//g' ${GOPATH}/pkg/mod/github.com/!kagami/go-face*/face.go \
# Build dependencies that use CGO
&& go install \
github.com/mattn/go-sqlite3 \
github.com/Kagami/go-face
COPY api /app/api
RUN source /app/scripts/set_compiler_env.sh \
&& go build -v -o photoview .
### Build release image ###
FROM --platform=${BUILDPLATFORM:-linux/amd64} debian:testing-slim AS release
ARG TARGETPLATFORM
2021-02-22 21:14:15 +01:00
# See for details: https://github.com/hadolint/hadolint/wiki/DL4006
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
COPY scripts/install_runtime_dependencies.sh /app/scripts/
RUN chmod +x /app/scripts/install_runtime_dependencies.sh \
# Create a user to run Photoview server
&& groupadd -g 999 photoview \
&& useradd -r -u 999 -g photoview -m photoview \
2021-02-25 15:38:09 +01:00
# Required dependencies
&& /app/scripts/install_runtime_dependencies.sh
2020-07-13 18:14:01 +02:00
Refactor docker deployment and user setup (#863) * Fix #862, address #826 and maybe some other tickets: reimplemented the docker-compose user setup to enhance product setup experience and cover much more cases. * make unique DB container name and use it in communication from Photoview * Removed unnecessary healthcheck for photoview from docker-compose.example.yml, as it is defined in the Dockerfile; optimized Dockerfile combining all RUN directives of PROD stage into 1, which will produce single layer and save some space; added Dockerfile-dev, docker-compose-dev.yml, and new "dev" and "dev-down" directives into Makefile, which allows to setup development env in Docker. Instructions of how to use it are in comments at the beginning of Dockerfile-dev and docker-compose-dev.yml files * Set RWX permissions to the application's working folder for any user, so that the image could be later run with non-root permissions and the app still be able to do needed operations in the FS * Enhanced the "Getting started" section in the readme; added the `help` target and enhanced comments in the Makefile; commented out the `docker system prune -f` with the comment about the command and why it is there; added optional and commented by default `7zz` commands to the `backup` section of the Makefile * Use `slim` base image for final photoview image * Implement SQLite support according to the PR #851 * Removed deprecated `version` line from compose files; optimized dockerfile to build with less layers and run as non-root; mapped only Photoview related services to Watchtower by default instead of updating all running images on a host; added template for Postgres to the .env; reverted compose executable definition, so the new compose is called when present; added a tip about `lnav` to help * fix a typo in the username; add support of PostgreSQL; split and optimize backup target in Makefile * Fixed some typos and styling in Readme, excluded dev-environment setup from the PR; added a list of tips on how to secure Photoview in the Advanced setup section of Readme * Implemented many security improvements, suggested by @Omar007, switched to the dedicated Darktable's repo to install the latest released version, as asked in #935; switched Watchtower to labels instead of profiles * forgot the compose file * move face models back to /app folder; comment out and document unnecessary vars in compose; fix a typo in a few vars * Exclude Makefile in the root folder from git; documented multiple mounts case better; fixed incorrect SQLite DB path * Fixed several bugs after complete testing cycle with all 3 DBs * removed hardcoded port in Dockerfile * Pin the major version for the `photoview` image for stability * Revert back to the port 80 inside the container on product owner's request * Provide a minimal compose file and update the readme accordingly * Handle incorrect media file and folder permissions; set correct permissions for storage folder; fix healthcheck command for postgres --------- Co-authored-by: Konstantin Koval <kkb@ukr.net>
2024-05-15 10:58:02 +02:00
WORKDIR /home/photoview
Refactor docker deployment and user setup (#863) * Fix #862, address #826 and maybe some other tickets: reimplemented the docker-compose user setup to enhance product setup experience and cover much more cases. * make unique DB container name and use it in communication from Photoview * Removed unnecessary healthcheck for photoview from docker-compose.example.yml, as it is defined in the Dockerfile; optimized Dockerfile combining all RUN directives of PROD stage into 1, which will produce single layer and save some space; added Dockerfile-dev, docker-compose-dev.yml, and new "dev" and "dev-down" directives into Makefile, which allows to setup development env in Docker. Instructions of how to use it are in comments at the beginning of Dockerfile-dev and docker-compose-dev.yml files * Set RWX permissions to the application's working folder for any user, so that the image could be later run with non-root permissions and the app still be able to do needed operations in the FS * Enhanced the "Getting started" section in the readme; added the `help` target and enhanced comments in the Makefile; commented out the `docker system prune -f` with the comment about the command and why it is there; added optional and commented by default `7zz` commands to the `backup` section of the Makefile * Use `slim` base image for final photoview image * Implement SQLite support according to the PR #851 * Removed deprecated `version` line from compose files; optimized dockerfile to build with less layers and run as non-root; mapped only Photoview related services to Watchtower by default instead of updating all running images on a host; added template for Postgres to the .env; reverted compose executable definition, so the new compose is called when present; added a tip about `lnav` to help * fix a typo in the username; add support of PostgreSQL; split and optimize backup target in Makefile * Fixed some typos and styling in Readme, excluded dev-environment setup from the PR; added a list of tips on how to secure Photoview in the Advanced setup section of Readme * Implemented many security improvements, suggested by @Omar007, switched to the dedicated Darktable's repo to install the latest released version, as asked in #935; switched Watchtower to labels instead of profiles * forgot the compose file * move face models back to /app folder; comment out and document unnecessary vars in compose; fix a typo in a few vars * Exclude Makefile in the root folder from git; documented multiple mounts case better; fixed incorrect SQLite DB path * Fixed several bugs after complete testing cycle with all 3 DBs * removed hardcoded port in Dockerfile * Pin the major version for the `photoview` image for stability * Revert back to the port 80 inside the container on product owner's request * Provide a minimal compose file and update the readme accordingly * Handle incorrect media file and folder permissions; set correct permissions for storage folder; fix healthcheck command for postgres --------- Co-authored-by: Konstantin Koval <kkb@ukr.net>
2024-05-15 10:58:02 +02:00
COPY api/data /app/data
COPY --from=ui /app/ui/dist /app/ui
COPY --from=api /app/api/photoview /app/photoview
2020-03-01 02:06:18 +01:00
ENV PHOTOVIEW_LISTEN_IP=127.0.0.1
ENV PHOTOVIEW_LISTEN_PORT=80
ENV PHOTOVIEW_SERVE_UI=1
ENV PHOTOVIEW_UI_PATH=/app/ui
ENV PHOTOVIEW_FACE_RECOGNITION_MODELS_PATH=/app/data/models
ENV PHOTOVIEW_MEDIA_CACHE=/home/photoview/media-cache
Refactor docker deployment and user setup (#863) * Fix #862, address #826 and maybe some other tickets: reimplemented the docker-compose user setup to enhance product setup experience and cover much more cases. * make unique DB container name and use it in communication from Photoview * Removed unnecessary healthcheck for photoview from docker-compose.example.yml, as it is defined in the Dockerfile; optimized Dockerfile combining all RUN directives of PROD stage into 1, which will produce single layer and save some space; added Dockerfile-dev, docker-compose-dev.yml, and new "dev" and "dev-down" directives into Makefile, which allows to setup development env in Docker. Instructions of how to use it are in comments at the beginning of Dockerfile-dev and docker-compose-dev.yml files * Set RWX permissions to the application's working folder for any user, so that the image could be later run with non-root permissions and the app still be able to do needed operations in the FS * Enhanced the "Getting started" section in the readme; added the `help` target and enhanced comments in the Makefile; commented out the `docker system prune -f` with the comment about the command and why it is there; added optional and commented by default `7zz` commands to the `backup` section of the Makefile * Use `slim` base image for final photoview image * Implement SQLite support according to the PR #851 * Removed deprecated `version` line from compose files; optimized dockerfile to build with less layers and run as non-root; mapped only Photoview related services to Watchtower by default instead of updating all running images on a host; added template for Postgres to the .env; reverted compose executable definition, so the new compose is called when present; added a tip about `lnav` to help * fix a typo in the username; add support of PostgreSQL; split and optimize backup target in Makefile * Fixed some typos and styling in Readme, excluded dev-environment setup from the PR; added a list of tips on how to secure Photoview in the Advanced setup section of Readme * Implemented many security improvements, suggested by @Omar007, switched to the dedicated Darktable's repo to install the latest released version, as asked in #935; switched Watchtower to labels instead of profiles * forgot the compose file * move face models back to /app folder; comment out and document unnecessary vars in compose; fix a typo in a few vars * Exclude Makefile in the root folder from git; documented multiple mounts case better; fixed incorrect SQLite DB path * Fixed several bugs after complete testing cycle with all 3 DBs * removed hardcoded port in Dockerfile * Pin the major version for the `photoview` image for stability * Revert back to the port 80 inside the container on product owner's request * Provide a minimal compose file and update the readme accordingly * Handle incorrect media file and folder permissions; set correct permissions for storage folder; fix healthcheck command for postgres --------- Co-authored-by: Konstantin Koval <kkb@ukr.net>
2024-05-15 10:58:02 +02:00
EXPOSE ${PHOTOVIEW_LISTEN_PORT}
2020-03-01 02:06:18 +01:00
Refactor docker deployment and user setup (#863) * Fix #862, address #826 and maybe some other tickets: reimplemented the docker-compose user setup to enhance product setup experience and cover much more cases. * make unique DB container name and use it in communication from Photoview * Removed unnecessary healthcheck for photoview from docker-compose.example.yml, as it is defined in the Dockerfile; optimized Dockerfile combining all RUN directives of PROD stage into 1, which will produce single layer and save some space; added Dockerfile-dev, docker-compose-dev.yml, and new "dev" and "dev-down" directives into Makefile, which allows to setup development env in Docker. Instructions of how to use it are in comments at the beginning of Dockerfile-dev and docker-compose-dev.yml files * Set RWX permissions to the application's working folder for any user, so that the image could be later run with non-root permissions and the app still be able to do needed operations in the FS * Enhanced the "Getting started" section in the readme; added the `help` target and enhanced comments in the Makefile; commented out the `docker system prune -f` with the comment about the command and why it is there; added optional and commented by default `7zz` commands to the `backup` section of the Makefile * Use `slim` base image for final photoview image * Implement SQLite support according to the PR #851 * Removed deprecated `version` line from compose files; optimized dockerfile to build with less layers and run as non-root; mapped only Photoview related services to Watchtower by default instead of updating all running images on a host; added template for Postgres to the .env; reverted compose executable definition, so the new compose is called when present; added a tip about `lnav` to help * fix a typo in the username; add support of PostgreSQL; split and optimize backup target in Makefile * Fixed some typos and styling in Readme, excluded dev-environment setup from the PR; added a list of tips on how to secure Photoview in the Advanced setup section of Readme * Implemented many security improvements, suggested by @Omar007, switched to the dedicated Darktable's repo to install the latest released version, as asked in #935; switched Watchtower to labels instead of profiles * forgot the compose file * move face models back to /app folder; comment out and document unnecessary vars in compose; fix a typo in a few vars * Exclude Makefile in the root folder from git; documented multiple mounts case better; fixed incorrect SQLite DB path * Fixed several bugs after complete testing cycle with all 3 DBs * removed hardcoded port in Dockerfile * Pin the major version for the `photoview` image for stability * Revert back to the port 80 inside the container on product owner's request * Provide a minimal compose file and update the readme accordingly * Handle incorrect media file and folder permissions; set correct permissions for storage folder; fix healthcheck command for postgres --------- Co-authored-by: Konstantin Koval <kkb@ukr.net>
2024-05-15 10:58:02 +02:00
HEALTHCHECK --interval=60s --timeout=10s \
CMD curl --fail http://localhost:${PHOTOVIEW_LISTEN_PORT}/api/graphql \
-X POST -H 'Content-Type: application/json' \
--data-raw '{"operationName":"CheckInitialSetup","variables":{},"query":"query CheckInitialSetup { siteInfo { initialSetup }}"}' \
|| exit 1
2021-10-02 16:50:24 +02:00
Refactor docker deployment and user setup (#863) * Fix #862, address #826 and maybe some other tickets: reimplemented the docker-compose user setup to enhance product setup experience and cover much more cases. * make unique DB container name and use it in communication from Photoview * Removed unnecessary healthcheck for photoview from docker-compose.example.yml, as it is defined in the Dockerfile; optimized Dockerfile combining all RUN directives of PROD stage into 1, which will produce single layer and save some space; added Dockerfile-dev, docker-compose-dev.yml, and new "dev" and "dev-down" directives into Makefile, which allows to setup development env in Docker. Instructions of how to use it are in comments at the beginning of Dockerfile-dev and docker-compose-dev.yml files * Set RWX permissions to the application's working folder for any user, so that the image could be later run with non-root permissions and the app still be able to do needed operations in the FS * Enhanced the "Getting started" section in the readme; added the `help` target and enhanced comments in the Makefile; commented out the `docker system prune -f` with the comment about the command and why it is there; added optional and commented by default `7zz` commands to the `backup` section of the Makefile * Use `slim` base image for final photoview image * Implement SQLite support according to the PR #851 * Removed deprecated `version` line from compose files; optimized dockerfile to build with less layers and run as non-root; mapped only Photoview related services to Watchtower by default instead of updating all running images on a host; added template for Postgres to the .env; reverted compose executable definition, so the new compose is called when present; added a tip about `lnav` to help * fix a typo in the username; add support of PostgreSQL; split and optimize backup target in Makefile * Fixed some typos and styling in Readme, excluded dev-environment setup from the PR; added a list of tips on how to secure Photoview in the Advanced setup section of Readme * Implemented many security improvements, suggested by @Omar007, switched to the dedicated Darktable's repo to install the latest released version, as asked in #935; switched Watchtower to labels instead of profiles * forgot the compose file * move face models back to /app folder; comment out and document unnecessary vars in compose; fix a typo in a few vars * Exclude Makefile in the root folder from git; documented multiple mounts case better; fixed incorrect SQLite DB path * Fixed several bugs after complete testing cycle with all 3 DBs * removed hardcoded port in Dockerfile * Pin the major version for the `photoview` image for stability * Revert back to the port 80 inside the container on product owner's request * Provide a minimal compose file and update the readme accordingly * Handle incorrect media file and folder permissions; set correct permissions for storage folder; fix healthcheck command for postgres --------- Co-authored-by: Konstantin Koval <kkb@ukr.net>
2024-05-15 10:58:02 +02:00
USER photoview
2020-03-01 02:06:18 +01:00
ENTRYPOINT ["/app/photoview"]