forked from cloudflare/sciuro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (54 loc) · 1.95 KB
/
Copy pathDockerfile
File metadata and controls
66 lines (54 loc) · 1.95 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
# https://hub.docker.com/_/alpine
FROM docker.io/alpine:3.24.1@sha256:28bd5fe8b56d1bd048e5babf5b10710ebe0bae67db86916198a6eec434943f8b AS alpine-base
FROM docker.io/golang:1.26.7 AS base
WORKDIR /work
COPY go.mod go.sum ./
RUN go mod download
COPY . .
FROM base AS test
RUN --mount=type=cache,target=/root/.cache/go-build \
go test ./...
FROM base AS test-coverage
RUN --mount=type=cache,target=/root/.cache/go-build \
go test -coverprofile=/coverage.txt -mod=readonly -covermode=atomic ./...
FROM scratch AS export-test-coverage
COPY --from=test-coverage /coverage.txt /
FROM docker.io/golangci/golangci-lint:v2.13.1 AS golangci-lint
FROM base AS check
COPY --from=golangci-lint /usr/bin/golangci-lint /usr/bin/
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/golangci-lint \
golangci-lint run ./...
FROM base AS dep-update
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
set -x && \
go get -u ./... && \
go mod tidy
FROM scratch AS export-dep-update
COPY --from=dep-update /work/go.mod /work/go.sum /
FROM registry.k8s.io/kustomize/kustomize:v5.8.1 AS kustomize
FROM alpine-base AS build-manifests
ARG TAG
COPY --from=kustomize /app/kustomize /usr/local/bin/
WORKDIR /work
COPY manifests ./manifests
RUN set -x && \
cd manifests/namespaced && \
kustomize edit set image ghcr.io/pfnet/sciuro:${TAG} && \
kustomize build >/stable.yaml
RUN set -x && \
cd manifests/non-namespaced && \
kustomize build >/cluster.yaml
FROM scratch AS export-manifests
COPY --from=build-manifests /stable.yaml /cluster.yaml /
FROM base AS build
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
CGO_ENABLED=0 go build -o /sciuro cmd/sciuro/main.go
FROM scratch AS export
COPY --from=build /sciuro /
FROM alpine-base
COPY --from=build /sciuro /
ENTRYPOINT ["/sciuro"]