gohttpserver/Dockerfile

52 lines
1.0 KiB
Docker
Raw Normal View History

2020-09-30 06:35:07 +00:00
## lint image
FROM golangci/golangci-lint@sha256:9ae3767101cd3468cdaea5b6573dadb358013e05ac38abe37d53646680fd386c AS linter
RUN mkdir -p /build
WORKDIR /build
COPY ./ ./
RUN golangci-lint run
## build image:
#ARG GO_VERSION=1.15
FROM golang:1.15-buster AS builder
2020-09-30 06:35:07 +00:00
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 GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.31.0
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
2020-09-30 06:35:07 +00:00
RUN go mod vendor
RUN tar -c . | bzip2 > /src.tbz2
## output image:
FROM debian:buster-slim AS final
2020-09-30 06:35:07 +00:00
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"]