FROM golang:alpine as builder ENV GO111MODULE=on ENV USER=appuser ENV UID=1000 RUN adduser \ --disabled-password \ --gecos "" \ --home "/nonexistent" \ --shell "/sbin/nologin" \ --no-create-home \ --uid "${UID}" \ "${USER}" RUN apk update && apk add --no-cache git ca-certificates tzdata sqlite build-base RUN mkdir /build COPY . /build/ WORKDIR /build COPY ./ ./ RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o bog . FROM scratch AS final LABEL author="Cajually " COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo COPY --from=builder /etc/passwd /etc/passwd COPY --from=builder /etc/group /etc/group COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=builder /build/bog / COPY --from=builder /build/server/views /server/views COPY --from=builder /build/default.toml / WORKDIR / USER appuser:appuser ENTRYPOINT ["/bog"] EXPOSE 8002