2021-01-17 15:59:08 +01:00
|
|
|
### Build UI ###
|
2021-04-05 23:18:38 +02:00
|
|
|
FROM --platform=${BUILDPLATFORM:-linux/amd64} node:15 as ui
|
2020-03-01 02:06:18 +01:00
|
|
|
|
2021-01-16 22:27:23 +01:00
|
|
|
ARG PHOTOVIEW_API_ENDPOINT
|
|
|
|
ENV PHOTOVIEW_API_ENDPOINT=${PHOTOVIEW_API_ENDPOINT}
|
2020-03-01 02:06:18 +01:00
|
|
|
|
2020-04-30 14:36:55 +02:00
|
|
|
# Set environment variable UI_PUBLIC_URL from build args, uses "/" as default
|
2020-04-15 21:16:36 +02:00
|
|
|
ARG UI_PUBLIC_URL
|
2020-04-30 14:36:55 +02:00
|
|
|
ENV UI_PUBLIC_URL=${UI_PUBLIC_URL:-/}
|
2020-04-15 21:16:36 +02:00
|
|
|
|
2020-03-01 02:06:18 +01:00
|
|
|
RUN mkdir -p /app
|
|
|
|
WORKDIR /app
|
|
|
|
|
2020-05-17 21:29:09 +02:00
|
|
|
# Download dependencies
|
2020-04-05 18:54:13 +02:00
|
|
|
COPY ui/package*.json /app/
|
2021-04-03 17:32:01 +02:00
|
|
|
RUN HUSKY=0 npm ci --only=production
|
2020-03-01 02:06:18 +01:00
|
|
|
|
2020-05-17 21:29:09 +02:00
|
|
|
# Build frontend
|
2021-02-25 15:38:09 +01:00
|
|
|
COPY ui /app
|
2020-04-15 21:16:36 +02:00
|
|
|
RUN npm run build -- --public-url $UI_PUBLIC_URL
|
2020-03-01 02:06:18 +01:00
|
|
|
|
2021-01-17 15:59:08 +01:00
|
|
|
### Build API ###
|
2021-03-28 13:57:57 +02:00
|
|
|
FROM --platform=${BUILDPLATFORM:-linux/amd64} debian:bullseye-slim AS api
|
|
|
|
ARG TARGETPLATFORM
|
|
|
|
|
|
|
|
COPY docker/install_build_dependencies.sh /tmp/
|
|
|
|
RUN chmod +x /tmp/install_build_dependencies.sh && /tmp/install_build_dependencies.sh
|
2021-02-15 23:17:37 +01:00
|
|
|
|
2021-02-22 19:46:47 +01:00
|
|
|
COPY docker/go_wrapper.sh /go/bin/go
|
2021-02-15 23:17:37 +01:00
|
|
|
RUN chmod +x /go/bin/go
|
2021-03-31 23:32:37 +02:00
|
|
|
ENV GOPATH="/go"
|
|
|
|
ENV PATH="${GOPATH}/bin:${PATH}"
|
2021-02-15 23:17:37 +01:00
|
|
|
|
|
|
|
ENV CGO_ENABLED 1
|
2020-08-09 20:32:02 +02:00
|
|
|
|
2020-12-09 19:24:39 +01:00
|
|
|
RUN go env
|
|
|
|
|
2020-05-17 21:29:09 +02:00
|
|
|
RUN mkdir -p /app
|
2020-03-01 02:06:18 +01:00
|
|
|
WORKDIR /app
|
2020-05-17 21:29:09 +02:00
|
|
|
|
|
|
|
# Download dependencies
|
|
|
|
COPY api/go.mod api/go.sum /app/
|
|
|
|
RUN go mod download
|
|
|
|
|
2021-02-25 15:38:09 +01:00
|
|
|
# Patch go-face
|
2021-03-31 23:32:37 +02:00
|
|
|
RUN sed -i 's/-march=native//g' ${GOPATH}/pkg/mod/github.com/!kagami/go-face*/face.go
|
2021-02-15 20:47:01 +01:00
|
|
|
|
2021-02-25 15:38:09 +01:00
|
|
|
# Build dependencies that use CGO
|
|
|
|
RUN go install \
|
|
|
|
github.com/mattn/go-sqlite3 \
|
|
|
|
github.com/Kagami/go-face
|
2021-02-15 23:17:37 +01:00
|
|
|
|
2021-02-25 15:38:09 +01:00
|
|
|
# Copy and build api source
|
2020-03-01 02:06:18 +01:00
|
|
|
COPY api /app
|
2020-08-09 20:57:28 +02:00
|
|
|
RUN go build -v -o photoview .
|
2020-03-01 02:06:18 +01:00
|
|
|
|
2021-01-17 15:59:08 +01:00
|
|
|
### Copy api and ui to production environment ###
|
2021-03-28 13:57:57 +02:00
|
|
|
FROM debian:bullseye-slim
|
2021-03-03 13:32:44 +01:00
|
|
|
ARG TARGETPLATFORM
|
2021-02-22 21:14:15 +01:00
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
COPY api/data /app/data
|
2020-03-01 02:06:18 +01:00
|
|
|
|
2021-02-25 15:38:09 +01:00
|
|
|
RUN apt-get update \
|
|
|
|
# Required dependencies
|
2021-03-29 12:10:02 +02:00
|
|
|
&& apt-get install -y curl gpg libdlib19 ffmpeg exiftool libheif1
|
2021-03-03 13:32:44 +01:00
|
|
|
|
|
|
|
# Install Darktable if building for a supported architecture
|
|
|
|
RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ] || [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
|
2021-03-28 13:57:57 +02:00
|
|
|
apt-get install -y darktable; fi
|
2021-03-03 13:32:44 +01:00
|
|
|
|
|
|
|
# Remove build dependencies and cleanup
|
|
|
|
RUN apt-get purge -y curl gpg \
|
|
|
|
&& apt-get autoremove -y \
|
|
|
|
&& apt-get clean \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
2020-07-13 18:14:01 +02:00
|
|
|
|
2020-03-01 02:06:18 +01:00
|
|
|
COPY --from=ui /app/dist /ui
|
|
|
|
COPY --from=api /app/photoview /app/photoview
|
|
|
|
|
2021-01-16 22:27:23 +01:00
|
|
|
ENV PHOTOVIEW_LISTEN_IP 127.0.0.1
|
|
|
|
ENV PHOTOVIEW_LISTEN_PORT 80
|
2020-04-30 14:59:29 +02:00
|
|
|
|
2021-01-16 22:27:23 +01:00
|
|
|
ENV PHOTOVIEW_SERVE_UI 1
|
2021-02-26 15:10:28 +01:00
|
|
|
ENV PHOTOVIEW_UI_PATH /ui
|
2020-04-30 14:59:29 +02:00
|
|
|
|
2020-03-01 02:06:18 +01:00
|
|
|
EXPOSE 80
|
|
|
|
|
|
|
|
ENTRYPOINT ["/app/photoview"]
|