Use self-building dependencies and update the code with imagemagick. (#1053)

This commit is contained in:
Googol Lee
2024-09-17 15:02:23 +02:00
committed by GitHub
parent 4b678f201d
commit 340c181442
17 changed files with 280 additions and 225 deletions

View File

@@ -49,13 +49,29 @@ ENV PATH="${GOPATH}/bin:${PATH}"
ENV CGO_ENABLED=1
# Download dependencies
COPY scripts/*.sh /app/scripts/
COPY scripts/set_compiler_env.sh /app/scripts/
RUN chmod +x /app/scripts/*.sh \
&& source /app/scripts/set_compiler_env.sh
COPY --from=viktorstrate/dependencies /artifacts.tar.gz /dependencies/
RUN export $(cat /env) \
&& cd /dependencies/ \
&& tar xfv artifacts.tar.gz \
&& cp -a include/* /usr/local/include/ \
&& cp -a pkgconfig/* ${PKG_CONFIG_PATH} \
&& cp -a lib/* /usr/local/lib/ \
&& cp -a bin/* /usr/local/bin/ \
&& ldconfig \
&& apt-get install -y ./deb/jellyfin-ffmpeg.deb
COPY scripts/install_*.sh /app/scripts/
RUN chmod +x /app/scripts/*.sh \
&& export $(cat /env) \
&& /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 \
RUN export $(cat /env) \
&& go env \
&& go mod download \
# Patch go-face
@@ -66,30 +82,44 @@ RUN source /app/scripts/set_compiler_env.sh \
github.com/Kagami/go-face
COPY api /app/api
RUN source /app/scripts/set_compiler_env.sh \
RUN export $(cat /env) \
&& go env \
&& go build -v -o photoview .
### Build release image ###
FROM --platform=${BUILDPLATFORM:-linux/amd64} debian:bookworm-slim AS release
FROM debian:bookworm-slim AS release
ARG TARGETPLATFORM
# 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 \
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
&& groupadd -g 999 photoview \
&& useradd -r -u 999 -g photoview -m photoview \
# Required dependencies
&& /app/scripts/install_runtime_dependencies.sh
WORKDIR /home/photoview
# Install required dependencies
&& /app/scripts/install_runtime_dependencies.sh \
# Install self-building libs
&& cd /dependencies \
&& cp -a lib/* /usr/local/lib/ \
&& cp -a bin/* /usr/local/bin/ \
&& ldconfig \
&& apt-get install -y ./deb/jellyfin-ffmpeg.deb \
&& ln -s /usr/lib/jellyfin-ffmpeg/ffmpeg /usr/local/bin/ \
&& ln -s /usr/lib/jellyfin-ffmpeg/ffprobe /usr/local/bin/ \
# Cleanup
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY api/data /app/data
COPY --from=ui /app/ui/dist /app/ui
COPY --from=api /app/api/photoview /app/photoview
WORKDIR /home/photoview
ENV PHOTOVIEW_LISTEN_IP=127.0.0.1
ENV PHOTOVIEW_LISTEN_PORT=80