This is my boilerplate for a Go http server project. Feedback and suggestions are encouraged!
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
gohttpserver/Dockerfile

44 righe
755 B

## lint image
FROM golangci/golangci-lint:v1.50.1
RUN mkdir -p /build
WORKDIR /build
COPY ./ ./
RUN golangci-lint run
## build image:
FROM golang:1.19.3-bullseye 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 make httpd && mv ./httpd /httpd
RUN go mod vendor
RUN tar -c . | bzip2 > /src.tbz2
## output image:
FROM debian:bullseye-slim AS final
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /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"]