-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
83 lines (66 loc) · 2.35 KB
/
Copy pathDockerfile
File metadata and controls
83 lines (66 loc) · 2.35 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
81
82
83
# Copyright 2026 ptrvsrg.
#
# Licensed under the Apache License, Version 2.0 (the License);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ARG GOLANG_VERSION=1.26.4
ARG ALPINE_VERSION=3.24
ARG KUBO_VERSION=v0.42.0
# Dependency stage
FROM golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION} AS deps
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
# Build stage
FROM deps AS builder
COPY . .
ARG TARGETOS
ARG TARGETARCH
ARG VERSION=dev
ARG GIT_COMMIT=unknown
ARG BUILD_DATE=unknown
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 \
go build \
-ldflags "-s -w \
-X main.driverVersion=${VERSION} \
-X main.gitCommit=${GIT_COMMIT} \
-X main.buildDate=${BUILD_DATE}" \
-o /bin/csi-driver-ipfs \
./cmd/csi-driver-ipfs/
# Build Kubo from the pinned upstream tag with local patches
FROM ipfs/kubo:${KUBO_VERSION} AS kubo
# Runtime stage
FROM alpine:${ALPINE_VERSION} AS runtime
ARG VERSION=dev
ARG GIT_COMMIT=unknown
ARG BUILD_DATE=unknown
LABEL org.opencontainers.image.title="csi-driver-ipfs" \
org.opencontainers.image.description="CSI driver for IPFS volumes" \
org.opencontainers.image.source="https://github.com/ptrvsrg/csi-driver-ipfs" \
org.opencontainers.image.commit="${GIT_COMMIT}" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.build-date="${BUILD_DATE}"
RUN apk upgrade --no-cache libcrypto3 libssl3 \
&& apk add --no-cache \
bash \
ca-certificates \
curl \
e2fsprogs \
make \
xfsprogs
COPY --from=kubo /usr/local/bin/ipfs /usr/local/bin/ipfs
COPY --from=builder /bin/csi-driver-ipfs /bin/csi-driver-ipfs
# Define a non-root image user by default; Kubernetes manifests override to
# root for CSI driver workloads that need mount/umount privileges.
RUN addgroup -S -g 65532 csiipfs \
&& adduser -S -D -H -u 65532 -G csiipfs -s /sbin/nologin csiipfs
USER 65532:65532
ENTRYPOINT ["/bin/csi-driver-ipfs"]