gohttpserver/Dockerfile
sneak d3c104685c
All checks were successful
continuous-integration/drone/push Build is passing
fixed gitignore which mistakenly omitted the cmd dir
2020-09-30 01:28:06 -07:00

52 lines
1.0 KiB
Docker

## 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-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 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
RUN go mod vendor
RUN tar -c . | bzip2 > /src.tbz2
## output image:
FROM ubuntu:focal 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"]