2021-01-17 15:59:08 +01:00
|
|
|
### Build UI ###
|
2020-08-09 20:32:02 +02:00
|
|
|
FROM --platform=${BUILDPLATFORM:-linux/amd64} node:10 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/
|
2020-03-01 02:06:18 +01:00
|
|
|
RUN npm install
|
|
|
|
COPY ui /app
|
|
|
|
|
2020-05-17 21:29:09 +02:00
|
|
|
# Build frontend
|
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-01-31 19:34:15 +01:00
|
|
|
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.15-buster AS api
|
2021-01-17 15:59:08 +01:00
|
|
|
|
2021-01-31 19:34:15 +01:00
|
|
|
# Install GCC cross compilers
|
|
|
|
RUN apt-get update
|
|
|
|
RUN apt-get install -y gcc-aarch64-linux-gnu libc6-dev-arm64-cross gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
|
2021-01-17 15:59:08 +01:00
|
|
|
|
2020-09-23 14:35:02 +02:00
|
|
|
COPY --from=tonistiigi/xx:golang / /
|
2020-08-09 20:32:02 +02:00
|
|
|
|
2020-12-09 19:24:39 +01:00
|
|
|
ARG TARGETPLATFORM
|
|
|
|
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-01-17 15:59:08 +01:00
|
|
|
# Build go-sqlite3 dependency with CGO
|
|
|
|
ENV CGO_ENABLED 1
|
|
|
|
RUN go install github.com/mattn/go-sqlite3
|
|
|
|
|
2020-05-17 21:29:09 +02:00
|
|
|
# Copy 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-01-31 20:58:14 +01:00
|
|
|
FROM debian:buster
|
2020-03-01 02:06:18 +01:00
|
|
|
|
2020-08-09 20:57:28 +02:00
|
|
|
# Install darktable for converting RAW images, and ffmpeg for encoding videos
|
2021-01-31 20:58:14 +01:00
|
|
|
RUN apt-get update
|
|
|
|
RUN apt-get install -y darktable; exit 0
|
|
|
|
RUN apt-get install -y ffmpeg; exit 0
|
|
|
|
RUN 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
|
2020-04-30 14:59:29 +02:00
|
|
|
|
2020-03-01 02:06:18 +01:00
|
|
|
EXPOSE 80
|
|
|
|
|
|
|
|
ENTRYPOINT ["/app/photoview"]
|