-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
39 lines (27 loc) · 975 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
29
30
31
32
33
34
35
36
37
38
39
# ---
FROM --platform=$BUILDPLATFORM registry-1.docker.io/library/alpine:latest as certs
RUN apk update && apk add --no-cache ca-certificates
# ---
FROM --platform=$BUILDPLATFORM registry-1.docker.io/library/golang:1.23-alpine as builder
WORKDIR /build/
COPY go.mod go.sum ./
RUN go mod download
ARG TARGETOS TARGETARCH VERSION
COPY . /build/
RUN go generate ./... \
&& CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -a -ldflags "-s -w -X main.version=${VERSION}" -o /build/blog ./main.go
# ---
FROM registry-1.docker.io/library/busybox:1.37.0
ARG TARGETOS TARGETARCH
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static-$TARGETARCH /tini
RUN chmod +x /tini
RUN mkdir /app
RUN addgroup -S app && adduser -S -G app app
WORKDIR /app
COPY --from=builder /build/blog .
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
RUN chown -R app:app .
USER app
EXPOSE 3000
ENTRYPOINT ["/tini", "--", "/app/blog"]