From 9098bf38d1fbead52d99636cd26dc5f9b3e56bbb Mon Sep 17 00:00:00 2001 From: viktorstrate Date: Sun, 17 Jan 2021 15:59:08 +0100 Subject: [PATCH] Make Dockerfile build sqlite dependency without errors --- Dockerfile | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 715e25c7..f5956ba3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -# Build UI +### Build UI ### FROM --platform=${BUILDPLATFORM:-linux/amd64} node:10 as ui ARG PHOTOVIEW_API_ENDPOINT @@ -19,8 +19,12 @@ COPY ui /app # Build frontend RUN npm run build -- --public-url $UI_PUBLIC_URL -# Build API -FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.14-alpine AS api +### 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 / / ARG TARGETPLATFORM @@ -33,13 +37,17 @@ WORKDIR /app 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 COPY api /app RUN go build -v -o photoview . -# Copy api and ui to production environment -FROM alpine:3.12 +### Copy api and ui to production environment ### +FROM alpine:3 # Install darktable for converting RAW images, and ffmpeg for encoding videos # Ignore errors if packages are not supported for the specific platform