-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
80 lines (54 loc) · 2.46 KB
/
Dockerfile
File metadata and controls
80 lines (54 loc) · 2.46 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
FROM --platform=${BUILDPLATFORM} node:24.12.0@sha256:929c026d5a4e4a59685b3c1dbc1a8c3eb090aa95373d3a4fd668daa2493c8331 AS web-builder
WORKDIR /src
COPY .yarnrc.yml package.json yarn.lock .
COPY .yarn .yarn
RUN --mount=type=cache,target=node_modules \
yarn install --immutable
COPY tsconfig.json vite.config.ts .
COPY web web
ARG CUPDATE_VERSION="development build"
RUN --mount=type=cache,target=node_modules \
VITE_CUPDATE_VERSION="${CUPDATE_VERSION}" yarn build
FROM --platform=${BUILDPLATFORM} golang:1.26.0@sha256:fb612b7831d53a89cbc0aaa7855b69ad7b0caf603715860cf538df854d047b84 AS osv-scanner-builder
ARG TARGETARCH
ARG TARGETOS
ARG OSV_SCANNER_REPO="https://github.com/google/osv-scanner"
# v2.3.3 (2026-02-12)
ARG OSV_SCANNER_REF="b97d1de7d8c3c7de8c11308b3d9cb5bbf3f7a0e9"
WORKDIR /src
# Use the toolchain specified in go.mod, or newer
ENV GOTOOLCHAIN=auto
RUN git clone --filter=tree:0 --depth=1 --no-checkout --sparse "${OSV_SCANNER_REPO}" . && \
git sparse-checkout init --sparse-index --cone && \
git sparse-checkout add cmd/osv-scanner internal pkg && \
git checkout "${OSV_SCANNER_REF}"
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
go mod download && go mod verify
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GOARCH=${TARGETARCH} GOOS=${TARGETOS} CGO_ENABLED=0 go build -a -ldflags="-s -w" -o osv-scanner ./cmd/osv-scanner/main.go
FROM --platform=${BUILDPLATFORM} golang:1.26.0@sha256:fb612b7831d53a89cbc0aaa7855b69ad7b0caf603715860cf538df854d047b84 AS builder
WORKDIR /src
# Use the toolchain specified in go.mod, or newer
ENV GOTOOLCHAIN=auto
COPY go.mod go.sum .
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
go mod download && go mod verify
COPY cmd cmd
COPY internal internal
COPY --from=web-builder /src/internal/web/public /src/internal/web/public
ARG CUPDATE_VERSION="development build"
ARG TARGETARCH
ARG TARGETOS
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GOARCH=${TARGETARCH} GOOS=${TARGETOS} CGO_ENABLED=0 go build -a -ldflags="-s -w -X 'main.Version=$CUPDATE_VERSION'" -o cupdate cmd/cupdate/*.go
FROM scratch AS export
COPY --from=builder /src/cupdate cupdate
FROM export
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=osv-scanner-builder /src/osv-scanner osv-scanner
ENV PATH=/
ENTRYPOINT ["cupdate"]