gohttpserver/Dockerfile

46 lines
819 B
Docker

## lint image
FROM golangci/golangci-lint@sha256:9ae3767101cd3468cdaea5b6573dadb358013e05ac38abe37d53646680fd386c AS linter
RUN mkdir -p /build
WORKDIR /build
COPY ./ ./
RUN golangci-lint run
## build image:
FROM golang:1.15-buster AS builder
RUN apt update && apt install -y make bzip2
RUN mkdir -p /build
WORKDIR /build
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY ./ ./
#RUN make lint
RUN find .
RUN make httpd
RUN go mod vendor
RUN tar -c . | bzip2 > /src.tbz2
## output image:
FROM debian:buster-slim AS final
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /build/httpd /app/httpd
COPY --from=builder /src.tbz2 /usr/local/src/src.tbz2
WORKDIR /app
ENV HOME /app
ENV PORT 8080
ENV DBURL none
EXPOSE 8080
USER nobody:nogroup
ENTRYPOINT ["/app/httpd"]