1- # syntax=docker/dockerfile:1.4
2-
31FROM golang:1.24 as build
4-
5- ENV TZ=UTC
6- RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
7-
82WORKDIR /build
9-
10- RUN go install github.com/go-task/task/v3/cmd/task@latest
11- RUN go install github.com/goreleaser/goreleaser@latest
12-
13- # Install dependencies
14- COPY --link go.mod go.sum ./
15-
3+ COPY go.mod go.sum ./
164RUN go mod tidy
17-
18- # Build binary
19- COPY --link Taskfile.yaml .goreleaser.yaml ./
20- COPY --link main.go ./
21- COPY --link pkg ./pkg
22- # For goreleaser, TODO: remove
23- COPY --link .git ./.git
24-
25- RUN task build
26-
5+ COPY . .
6+ RUN go mod tidy && go mod download
7+ ARG VERSION
8+ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
9+ go build \
10+ -ldflags "-s -w \
11+ -X main.name=csi-hyperstack \
12+ -X main.version=${VERSION} \
13+ -X k8s.io/csi-hyperstack/pkg/driver.DriverName=hyperstack.csi.nexgencloud.com \
14+ -X k8s.io/csi-hyperstack/pkg/driver.DriverVersion=${VERSION}" \
15+ -o /csi-hyperstack
2716
2817FROM alpine:3.20 as runtime
29-
30- RUN apk add --no-cache --update \
31- ca-certificates \
32- bash \
33- vim \
34- curl
35-
36- RUN curl -o /usr/local/bin/gosu \
37- -fsSL "https://github.com/tianon/gosu/releases/download/1.12/gosu-amd64" \
38- && chmod +x /usr/local/bin/gosu
39-
40- RUN curl -fsSL "https://github.com/fullstorydev/grpcurl/releases/download/v1.7.0/grpcurl_1.7.0_linux_x86_64.tar.gz" -o grpcurl_1.7.0_linux_x86_64.tar.gz \
41- && tar -xvf grpcurl_1.7.0_linux_x86_64.tar.gz \
42- && chmod +x grpcurl
43- RUN apk add e2fsprogs
44- ENV HOME="/app"
45- ENV PATH="/app:$PATH"
46- WORKDIR "${HOME}"
47-
48- ENV ELEVATED_USER "false"
49- ENV GROUP_ID 1000
50- ENV GROUP_NAME app
51- ENV USER_ID 1000
52- ENV USER_NAME app
53- RUN addgroup -g "${GROUP_ID}" "${GROUP_NAME}" \
54- && adduser -u "${USER_ID}" -G "${GROUP_NAME}" -h "${HOME}" -D "${USER_NAME}"
55-
56- COPY --link build/entrypoint.sh entrypoint.sh
57- RUN chmod +x entrypoint.sh
58-
59- COPY --link --from=build /build/dist/csi-hyperstack .
18+ RUN apk add --no-cache --update e2fsprogs
19+ RUN wget "https://github.com/fullstorydev/grpcurl/releases/download/v1.7.0/grpcurl_1.7.0_linux_x86_64.tar.gz" \
20+ && tar -xvf grpcurl_1.7.0_linux_x86_64.tar.gz -C /usr/local/bin grpcurl \
21+ && chmod +x /usr/local/bin/grpcurl \
22+ && rm -rf grpcurl_1.7.0_linux_x86_64.tar.gz
23+ COPY --from=build /csi-hyperstack .
6024RUN chmod +x csi-hyperstack
61-
62- ENV LOCAL_HEALTH_PORT "8080"
63- HEALTHCHECK --interval=5s --timeout=3s --start-period=5s --retries=1 \
64- CMD curl -f "http://localhost:${LOCAL_HEALTH_PORT}/health" || exit 1
6525RUN mkdir -p /csi
66- # ENTRYPOINT ["entrypoint.sh"]
67- # CMD ["csi-hyperstack", "start", "--endpoint", "unix:///csi/csi.sock", "--hyperstack-cluster-id", "''", "--hyperstack-node-id", "''", "--service-controller-enabled", "--service-node-enabled"]
26+ ENTRYPOINT ["/csi-hyperstack" ]
0 commit comments