-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
28 lines (19 loc) · 877 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Build the application from source.
FROM golang:1.23.3-alpine@sha256:09742590377387b931261cbeb72ce56da1b0d750a27379f7385245b2b058b63a AS go-builder
ENV GOCACHE="/cache/go-build" \
# Disable CGO to build a static binary.
CGO_ENABLED=0
WORKDIR /app
COPY go.mod go.sum cmd ./
RUN --mount=type=cache,target=${GOCACHE} \
go build -o /app/dist/deadnews-template-go ./...
# Deploy the application binary into a lean image.
FROM gcr.io/distroless/static-debian12:debug@sha256:6a237461502fc122b76112a49945e0bf1b0a358b2455f38fd383241281696709 AS runtime
LABEL maintainer="DeadNews <deadnewsgit@gmail.com>"
ENV SERVICE_PORT=8000
COPY --from=go-builder /app/dist/deadnews-template-go /bin/deadnews-template-go
RUN ["/busybox/sh", "-c", "ln -s /busybox/sh /bin/sh"]
USER nonroot:nonroot
EXPOSE ${SERVICE_PORT}
HEALTHCHECK NONE
ENTRYPOINT ["/bin/deadnews-template-go"]