1
Fork 0
photoview/Dockerfile

68 lines
1.4 KiB
Docker
Raw Normal View History

### 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
ARG PHOTOVIEW_API_ENDPOINT
ENV PHOTOVIEW_API_ENDPOINT=${PHOTOVIEW_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:-/}
2020-03-01 02:06:18 +01:00
RUN mkdir -p /app
WORKDIR /app
# Download dependencies
COPY ui/package*.json /app/
2020-03-01 02:06:18 +01:00
RUN npm install
COPY ui /app
# Build frontend
RUN npm run build -- --public-url $UI_PUBLIC_URL
2020-03-01 02:06:18 +01:00
### Build API ###
FROM --platform=${BUILDPLATFORM:-linux/amd64} alpine:3 AS api
# Install required build dependencies
RUN apk --no-cache add go build-base
COPY --from=tonistiigi/xx:golang / /
2020-08-09 20:32:02 +02:00
ARG TARGETPLATFORM
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
# Build go-sqlite3 dependency with CGO
ENV CGO_ENABLED 1
RUN go install github.com/mattn/go-sqlite3
# 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
### Copy api and ui to production environment ###
FROM alpine:3
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
# Ignore errors if packages are not supported for the specific platform
2020-08-09 20:57:28 +02:00
RUN apk --no-cache add darktable; exit 0
RUN apk --no-cache add ffmpeg; exit 0
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
ENV PHOTOVIEW_LISTEN_IP 127.0.0.1
ENV PHOTOVIEW_LISTEN_PORT 80
ENV PHOTOVIEW_SERVE_UI 1
2020-03-01 02:06:18 +01:00
EXPOSE 80
ENTRYPOINT ["/app/photoview"]