This is my boilerplate for a Go http server project. Feedback and suggestions are encouraged!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
829B

  1. ## lint image
  2. FROM golangci/golangci-lint@sha256:9ae3767101cd3468cdaea5b6573dadb358013e05ac38abe37d53646680fd386c AS linter
  3. RUN mkdir -p /build
  4. WORKDIR /build
  5. COPY ./ ./
  6. RUN golangci-lint run
  7. ## build image:
  8. FROM golang:1.15-buster AS builder
  9. RUN apt update && apt install -y make bzip2
  10. RUN mkdir -p /build
  11. WORKDIR /build
  12. COPY go.mod .
  13. COPY go.sum .
  14. RUN go mod download
  15. COPY ./ ./
  16. #RUN make lint
  17. RUN make rice-install && make httpd
  18. RUN go mod vendor
  19. RUN tar -c . | bzip2 > /src.tbz2
  20. ## output image:
  21. FROM debian:buster-slim AS final
  22. COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
  23. COPY --from=builder /build/httpd /app/httpd
  24. COPY --from=builder /src.tbz2 /usr/local/src/src.tbz2
  25. WORKDIR /app
  26. ENV HOME /app
  27. ENV PORT 8080
  28. ENV DBURL none
  29. EXPOSE 8080
  30. USER nobody:nogroup
  31. ENTRYPOINT ["/app/httpd"]