1
Fork 0
photoview/Dockerfile

63 lines
1.3 KiB
Docker
Raw Normal View History

2020-03-01 02:06:18 +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
ARG API_ENDPOINT
ENV API_ENDPOINT=${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
2020-08-09 20:32:02 +02:00
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.14-alpine AS api
# Convert TARGETPLATFORM to GOARCH format
# https://github.com/tonistiigi/xx
COPY --from=tonistiigi/xx:golang / /
ARG TARGETPLATFORM
2020-03-01 02:06:18 +01:00
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
# Copy api source
2020-03-01 02:06:18 +01:00
COPY api /app
2020-08-09 20:32:02 +02:00
RUN go env && go build -v -o photoview .
2020-03-01 02:06:18 +01:00
# Copy api and ui to production environment
2020-06-20 13:21:07 +02:00
FROM alpine:3.12
2020-03-01 02:06:18 +01:00
2020-06-20 13:21:07 +02:00
# Install darktable for converting RAW images
RUN apk --no-cache add darktable
2020-07-13 18:14:01 +02:00
# Install ffmpeg for encoding videos
RUN apk --no-cache add ffmpeg
2020-03-01 02:06:18 +01:00
COPY --from=ui /app/dist /ui
COPY --from=api /app/database/migrations /database/migrations
COPY --from=api /app/photoview /app/photoview
ENV API_LISTEN_IP 127.0.0.1
ENV API_LISTEN_PORT 80
ENV SERVE_UI 1
2020-03-01 02:06:18 +01:00
EXPOSE 80
ENTRYPOINT ["/app/photoview"]