1
Fork 0
photoview/Dockerfile

104 lines
2.6 KiB
Docker
Raw Normal View History

### 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-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
2020-03-01 02:06:18 +01:00
RUN mkdir -p /app
WORKDIR /app
# Download dependencies
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
# Build frontend
2021-02-25 15:38:09 +01:00
COPY ui /app
RUN npm run build -- --public-url $UI_PUBLIC_URL
2020-03-01 02:06:18 +01:00
### Build API ###
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
RUN go env
RUN mkdir -p /app
2020-03-01 02:06:18 +01:00
WORKDIR /app
# 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-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
### Copy api and ui to production environment ###
FROM debian:bullseye-slim
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
&& apt-get install -y curl gpg libdlib19 ffmpeg exiftool libheif1
# Install Darktable if building for a supported architecture
RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ] || [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
apt-get install -y darktable; fi
# Remove build dependencies and cleanup
RUN apt-get purge -y gpg \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
2020-07-13 18:14:01 +02:00
2021-07-15 17:43:07 +02:00
COPY --from=ui /app/build /ui
2020-03-01 02:06:18 +01:00
COPY --from=api /app/photoview /app/photoview
ENV PHOTOVIEW_LISTEN_IP 127.0.0.1
ENV PHOTOVIEW_LISTEN_PORT 80
ENV PHOTOVIEW_SERVE_UI 1
ENV PHOTOVIEW_UI_PATH /ui
2020-03-01 02:06:18 +01:00
EXPOSE 80
2021-10-02 16:50:24 +02:00
HEALTHCHECK --interval=60s --timeout=10s CMD curl --fail 'http://localhost:80/api/graphql' -X POST -H 'Content-Type: application/json' --data-raw '{"operationName":"CheckInitialSetup","variables":{},"query":"query CheckInitialSetup { siteInfo { initialSetup }}"}'
2020-03-01 02:06:18 +01:00
ENTRYPOINT ["/app/photoview"]