-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
37 lines (28 loc) · 929 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
FROM --platform=$BUILDPLATFORM golang:1.23.3-alpine as builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# Set Golang build envs based on Docker platform string
ARG TARGETPLATFORM
RUN --mount=type=cache,target=/root/.cache \
set -x \
&& case "$TARGETPLATFORM" in \
'linux/amd64') export GOARCH=amd64 ;; \
'linux/arm/v6') export GOARCH=arm GOARM=6 ;; \
'linux/arm/v7') export GOARCH=arm GOARM=7 ;; \
'linux/arm64') export GOARCH=arm64 ;; \
*) echo "Unsupported target: $TARGETPLATFORM" && exit 1 ;; \
esac \
&& go build -ldflags='-w -s' -trimpath
FROM alpine:3.20
WORKDIR /app
RUN apk add --no-cache tzdata
COPY --from=builder /app/domain-watch /usr/local/bin/
ARG USERNAME=domain-watch
ARG UID=1000
ARG GID=$UID
RUN addgroup -g "$GID" "$USERNAME" \
&& adduser -S -u "$UID" -G "$USERNAME" "$USERNAME"
USER $UID
ENTRYPOINT ["domain-watch"]