Files
mtusi2026lab4/Dockerfile
T

34 lines
555 B
Docker

FROM golang:1.26.3 AS build
WORKDIR /src
ENV GOTOOLCHAIN=local
ENV CGO_ENABLED=0
COPY go.mod go.sum ./
RUN go mod download
COPY cmd ./cmd
COPY internal ./internal
RUN go vet ./... \
&& go test ./... \
&& go build -trimpath -ldflags="-s -w" -o /out/server ./cmd/server
FROM scratch
COPY --from=build /out/server /server
USER 65532:65532
ENV APP_HOST=0.0.0.0
ENV APP_PORT=8080
EXPOSE 8080
STOPSIGNAL SIGTERM
HEALTHCHECK --interval=5s --timeout=3s --start-period=5s --retries=3 \
CMD ["/server", "healthcheck"]
ENTRYPOINT ["/server"]