-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
37 lines (28 loc) · 946 Bytes
/
Copy pathDockerfile
File metadata and controls
37 lines (28 loc) · 946 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
34
35
36
37
FROM --platform=$BUILDPLATFORM golang:1.24 AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY main.go ./main.go
COPY cmd ./cmd
COPY internal ./internal
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
RUN set -eu; \
mkdir -p /app/bin; \
if [ "${TARGETARCH}" = "arm" ]; then \
case "${TARGETVARIANT}" in \
v6) GOARM="6" ;; \
v7) GOARM="7" ;; \
*) echo "Unsupported TARGETVARIANT=${TARGETVARIANT} for arm" >&2; exit 1 ;; \
esac; \
CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH}" GOARM="${GOARM}" \
go build -trimpath -ldflags="-s -w" -o /app/bin/mtsh main.go; \
else \
CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH}" \
go build -trimpath -ldflags="-s -w" -o /app/bin/mtsh main.go; \
fi
FROM alpine:3.20
COPY --from=builder /app/bin/mtsh /usr/local/bin/mtsh
ENTRYPOINT ["/usr/local/bin/mtsh"]
CMD ["server", "-v", "--dm-only"]