1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-17 09:37:02 +00:00

docker: Fix + some tweaks, fixes #155

- Reorder deps & builds
- Download elm binary
- g++ and python3 for node-gyp
- Bump go & alpine versions
- Use npm ci
This commit is contained in:
James Hillyerd
2020-03-29 20:15:33 -07:00
parent da63e4d77a
commit 2c74268014

View File

@@ -1,22 +1,30 @@
# Docker build file for Inbucket: https://www.inbucket.org/
# Build
FROM golang:1.12-alpine3.10 as builder
RUN apk add --no-cache --virtual .build-deps git make npm
# Install build-time dependencies
FROM golang:1.14-alpine3.11 as builder
RUN apk add --no-cache --virtual .build-deps g++ git make npm python3
WORKDIR /build
COPY . .
ENV CGO_ENABLED 0
RUN make clean deps
WORKDIR /build/ui
RUN rm -rf dist elm-stuff node_modules
RUN npm ci
ADD https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz elm.gz
RUN gunzip elm.gz && chmod 755 elm && mv elm /usr/bin/
# Build server
WORKDIR /build
RUN go build -o inbucket \
-ldflags "-X 'main.version=$(git describe --tags --always)' -X 'main.date=$(date -Iseconds)'" \
-v ./cmd/inbucket
# Build frontend
WORKDIR /build/ui
RUN rm -rf dist elm-stuff node_modules
RUN npm i
RUN npm run build
# Run in minimal image
FROM alpine:3.10
FROM alpine:3.11
WORKDIR /opt/inbucket
RUN mkdir bin defaults ui
COPY --from=builder /build/inbucket bin