historyposter/Dockerfile

38 lines
886 B
Docker
Raw Normal View History

2020-09-21 20:04:20 +00:00
## build image:
ARG GO_VERSION=1.15
FROM golang:${GO_VERSION}-alpine AS builder
RUN mkdir /user && \
echo 'nobody:x:65534:65534:nobody:/:' > /user/passwd && \
echo 'nobody:x:65534:' > /user/group
RUN apk add --no-cache ca-certificates git bzip2 make gcc libc-dev
RUN mkdir -p /go/src/git.eeqj.de/sneak/historyposter
WORKDIR /go/src/git.eeqj.de/sneak/historyposter
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY ./ ./
RUN make build
RUN tar -c /go | bzip2 > /go.tbz2
## output image:
FROM scratch as final
COPY --from=builder /user/group /user/passwd /etc/
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /go/src/git.eeqj.de/sneak/historyposter/historyposter /app/historyposter
COPY --from=builder /go.tbz2 /go.tbz2
WORKDIR /app
ENV PORT 8080
ENV DBURL none
EXPOSE 8080
USER nobody:nobody
ENTRYPOINT ["./historyposter"]