-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_example.Dockerfile
More file actions
33 lines (22 loc) · 830 Bytes
/
Copy pathapp_example.Dockerfile
File metadata and controls
33 lines (22 loc) · 830 Bytes
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
FROM --platform=$BUILDPLATFORM golang:1.24 AS builder
ARG TARGETARCH=amd64
ARG VERSION=devbuild
ARG COMMIT
WORKDIR /build
COPY go.* ./
RUN go mod download
COPY . .
RUN mkdir bin && CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build -ldflags="-s -w -X 'github.com/sedmess/go-ctx/ctx/appinfo.Version=$VERSION' -X 'github.com/sedmess/go-ctx/ctx/appinfo.BuildInfo=build $COMMIT ($(date)'" -o ./bin/app-$TARGETARCH ./
FROM alpine:3.21
ARG TARGETARCH=amd64
ARG VERSION=devbuild
ARG DATE
ARG COMMIT
ARG UID=65501
LABEL version="$VERSION" buildDate="$DATE" buildCommit="$COMMIT" gid="$UID" uid="$UID"
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app
COPY --from=builder /build/bin/app-$TARGETARCH /app/app
RUN adduser -u "$UID" -s /sbin/nologin -D app && chown "$UID:$UID" /app/app
USER app
ENTRYPOINT ["/app/app"]