-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (41 loc) · 1.25 KB
/
Copy pathDockerfile
File metadata and controls
60 lines (41 loc) · 1.25 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# syntax=docker/dockerfile:1
# check=error=true
# Latest version: https://hub.docker.com/_/golang/tags
FROM golang:1.26.2-trixie AS base
WORKDIR /src
RUN apt-get update \
&& apt-get install --assume-yes --no-install-recommends \
ca-certificates \
tree \
git \
openssh-client
FROM base AS builder-download
ARG GOARCH=amd64
COPY go.mod .
COPY go.sum .
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
FROM builder-download AS build
COPY . .
ARG GOOS=linux
ARG GOARCH=amd64
ARG GO_MODULE=github.com/specsnl/specs-cli
ARG SPECS_VERSION=dev
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go generate \
&& CGO_ENABLED=0 GOOS=$GOOS GOARCH=$GOARCH go build \
-trimpath \
-tags netgo \
-ldflags "-s -w -X ${GO_MODULE}/internal/cmd.Version=${SPECS_VERSION}" -o ./specs
# Latest version: https://hub.docker.com/_/debian/tags
FROM debian:13.4-slim
COPY --from=build /src/specs /usr/local/bin
CMD ["specs"]
FROM scratch AS binary
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs
COPY --from=build /src/specs /
COPY --from=build /etc/passwd /etc/passwd
CMD ["/specs"]
FROM scratch AS export
COPY --from=build /src/specs /specs