FROM golang:1.18.5 as builder ARG GOOS="linux" ARG GOARCH="amd64" WORKDIR /workspace COPY go.mod go.sum /workspace/ RUN go mod download COPY . . RUN CGO_ENABLED=0 go build -a -o hugo-mx-gateway FROM alpine:3.16.2 ARG RUNTIME_USER="mxgateway" ARG RUNTIME_USER_UID=4583 RUN apk update && apk add --no-cache ca-certificates RUN addgroup -g $RUNTIME_USER_UID $RUNTIME_USER && \ adduser --disabled-password --no-create-home --gecos "" \ --home /app --ingroup $RUNTIME_USER --uid $RUNTIME_USER_UID $RUNTIME_USER WORKDIR /app COPY --from=builder /workspace/hugo-mx-gateway . COPY entrypoint.sh LICENSE /app/ COPY templates /app/templates RUN chown -R $RUNTIME_USER:$RUNTIME_USER /app ENTRYPOINT ["sh", "./entrypoint.sh"]