-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (48 loc) · 1.91 KB
/
Copy pathDockerfile
File metadata and controls
59 lines (48 loc) · 1.91 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
# syntax=docker/dockerfile:1
# check=skip=InvalidDefaultArgInFrom
# ---- builder ----
FROM registry.suse.com/bci/golang:1.26 AS builder
ENV GOTOOLCHAIN=auto
ARG MK_HOST_ARCH
ENV ARCH=${MK_HOST_ARCH}
RUN zypper -n rm container-suseconnect && \
zypper -n install git curl gzip tar wget awk
COPY --from=golangci/golangci-lint:v2.12.2-alpine@sha256:91b27804074a0bacea298707f016911e60cf0cdbc6c7bf5ccacb5f0606d18d60 \
/usr/bin/golangci-lint /usr/local/bin/golangci-lint
ENV HOME=/go/src/github.com/harvester/harvester-csi-driver
WORKDIR ${HOME}
# ---- base ----
FROM builder AS base
COPY . .
# ---- build ----
FROM base AS build
ARG MK_REPO_ID
RUN --mount=type=cache,id=harvester-csi-driver-go-mod-${MK_REPO_ID},target=/go/pkg/mod \
--mount=type=cache,id=harvester-csi-driver-go-build-${MK_REPO_ID},target=/root/.cache/go-build \
./scripts/build
# ---- build-output ----
FROM scratch AS build-output
COPY --from=build /go/src/github.com/harvester/harvester-csi-driver/bin/ /
# ---- validate ----
FROM base AS validate
ARG MK_REPO_ID
RUN --mount=type=cache,id=harvester-csi-driver-go-mod-${MK_REPO_ID},target=/go/pkg/mod \
--mount=type=cache,id=harvester-csi-driver-go-build-${MK_REPO_ID},target=/root/.cache/go-build \
./scripts/validate
# ---- validate-ci ----
FROM base AS validate-ci
ARG MK_REPO_ID
RUN git init -q && \
git config user.email ci@harvester.local && \
git config user.name ci && \
git add -A && \
git commit -q -m ci
RUN --mount=type=cache,id=harvester-csi-driver-go-mod-${MK_REPO_ID},target=/go/pkg/mod \
--mount=type=cache,id=harvester-csi-driver-go-build-${MK_REPO_ID},target=/root/.cache/go-build \
./scripts/validate-ci
# ---- test ----
FROM base AS test
ARG MK_REPO_ID
RUN --mount=type=cache,id=harvester-csi-driver-go-mod-${MK_REPO_ID},target=/go/pkg/mod \
--mount=type=cache,id=harvester-csi-driver-go-build-${MK_REPO_ID},target=/root/.cache/go-build \
./scripts/test