gohttpserver/Dockerfile

45 lines
755 B
Docker
Raw Normal View History

2020-09-30 06:35:07 +00:00
## lint image
2022-11-28 01:06:30 +00:00
FROM golangci/golangci-lint:v1.50.1
2020-09-30 06:35:07 +00:00
RUN mkdir -p /build
WORKDIR /build
COPY ./ ./
RUN golangci-lint run
## build image:
2022-11-28 01:06:30 +00:00
FROM golang:1.19.3-bullseye AS builder
2020-09-30 06:35:07 +00:00
2020-10-01 06:04:47 +00:00
RUN apt update && apt install -y make bzip2
2020-09-30 06:35:07 +00:00
RUN mkdir -p /build
WORKDIR /build
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY ./ ./
#RUN make lint
2022-11-28 01:06:30 +00:00
RUN make httpd && mv ./httpd /httpd
2020-09-30 06:35:07 +00:00
RUN go mod vendor
RUN tar -c . | bzip2 > /src.tbz2
## output image:
2022-11-28 01:06:30 +00:00
FROM debian:bullseye-slim AS final
2020-09-30 06:35:07 +00:00
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
2022-11-28 01:06:30 +00:00
COPY --from=builder /httpd /app/httpd
2020-09-30 06:35:07 +00:00
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"]