Small Dockerfile improvements (#1246)

* Small Dockerfile improvements + a cleaner image rotation condition

* quoting

* Revert the change in the `magickwand.go`

---------

Co-authored-by: Konstantin Koval
This commit is contained in:
Kostiantyn
2025-07-18 17:51:11 +03:00
committed by GitHub
parent 69915575d5
commit 5b952b04b8

View File

@@ -45,8 +45,6 @@ ARG TARGETPLATFORM
# See for details: https://github.com/hadolint/hadolint/wiki/DL4006
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
WORKDIR /app/api
ENV GOPATH="/go"
ENV PATH="${GOPATH}/bin:${PATH}"
ENV CGO_ENABLED=1
@@ -57,22 +55,19 @@ RUN chmod +x /app/scripts/*.sh \
&& source /app/scripts/set_compiler_env.sh
COPY scripts/install_*.sh /app/scripts/
# Split values in `/env`
# hadolint ignore=SC2046
RUN chmod +x /app/scripts/*.sh \
&& export $(cat /env) \
&& set -a && source /env && set +a \
&& /app/scripts/install_build_dependencies.sh \
&& /app/scripts/install_runtime_dependencies.sh
# hadolint ignore=DL3022
COPY --from=photoview/dependencies:latest /artifacts.tar.gz /dependencies/
# Split values in `/env`
# hadolint ignore=SC2046
RUN export $(cat /env) \
WORKDIR /dependencies
RUN set -a && source /env && set +a \
&& git config --global --add safe.directory /app \
&& cd /dependencies/ \
&& tar xfv artifacts.tar.gz \
&& cp -a include/* /usr/local/include/ \
&& cp -a pkgconfig/* ${PKG_CONFIG_PATH} \
&& cp -a pkgconfig/* "${PKG_CONFIG_PATH}" \
&& cp -a lib/* /usr/local/lib/ \
&& ldconfig \
&& apt-get install -y ./deb/jellyfin-ffmpeg.deb \
@@ -80,9 +75,8 @@ RUN export $(cat /env) \
&& ln -s /usr/lib/jellyfin-ffmpeg/ffprobe /usr/local/bin/
COPY api/go.mod api/go.sum /app/api/
# Split values in `/env`
# hadolint ignore=SC2046
RUN export $(cat /env) \
WORKDIR /app/api
RUN set -a && source /env && set +a \
&& go env \
&& go mod download \
# Patch go-face
@@ -93,9 +87,7 @@ RUN export $(cat /env) \
github.com/Kagami/go-face
COPY api /app/api
# Split values in `/env`
# hadolint ignore=SC2046
RUN export $(cat /env) \
RUN set -a && source /env && set +a \
&& go env \
&& go build -v -o photoview .
@@ -107,6 +99,7 @@ ARG TARGETPLATFORM
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
COPY scripts/install_runtime_dependencies.sh /app/scripts/
WORKDIR /dependencies
RUN --mount=type=bind,from=api,source=/dependencies/,target=/dependencies/ \
chmod +x /app/scripts/install_runtime_dependencies.sh \
# Create a user to run Photoview server
@@ -115,7 +108,6 @@ RUN --mount=type=bind,from=api,source=/dependencies/,target=/dependencies/ \
# Install required dependencies
&& /app/scripts/install_runtime_dependencies.sh \
# Install self-building libs
&& cd /dependencies \
&& cp -a lib/*.so* /usr/local/lib/ \
&& ldconfig \
&& apt-get install -y ./deb/jellyfin-ffmpeg.deb \
@@ -153,5 +145,6 @@ HEALTHCHECK --interval=60s --timeout=10s \
--data-raw '{"operationName":"CheckInitialSetup","variables":{},"query":"query CheckInitialSetup { siteInfo { initialSetup }}"}' \
|| exit 1
LABEL org.opencontainers.image.source=https://github.com/photoview/photoview/
USER photoview
ENTRYPOINT ["/app/photoview"]