-
-
Notifications
You must be signed in to change notification settings - Fork 481
/
Copy pathDockerfile
31 lines (22 loc) · 773 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
# https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/
FROM --platform=$BUILDPLATFORM golang:1.21-alpine AS builder
ARG VERSION="dev"
ARG COMMIT="unknown"
ARG COMMIT_DATE="unknown"
WORKDIR /
COPY . .
ARG TARGETOS
ARG TARGETARCH
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build -trimpath \
-ldflags "-s -w \
-X github.com/iyear/tdl/pkg/consts.Version=${VERSION} \
-X github.com/iyear/tdl/pkg/consts.Commit=${COMMIT} \
-X github.com/iyear/tdl/pkg/consts.CommitDate=${COMMIT_DATE}" \
-o tdl
FROM alpine:latest
RUN apk add --no-cache ca-certificates
COPY --from=builder /tdl /usr/bin/tdl
ENTRYPOINT ["tdl"]