Skip to content

Commit 9fb826b

Browse files
feat: add ChunkStreams, optimized docker build, and support for extra env vars in csi nodeplugin rclone container (#60)
Details: * Updated to use Dockerfile syntax version `1.7+`. * Added `--mount=type=cache` for Go module and build cache. * Applied Go build optimizations: `-trimpath`, `-buildvcs=false`, and `-ldflags='-s -w'`. * Installed dependencies using `--no-install-recommends` to minimize image size. * Added a new `ChunkStreams` field to support concurrent chunk reading. * Support for extra env vars in csi nodeplugin rclone container.
1 parent bae35b6 commit 9fb826b

4 files changed

Lines changed: 23 additions & 6 deletions

File tree

Dockerfile

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,23 @@ FROM ${RCLONE_IMAGE_REPOSITORY}:${RCLONE_IMAGE_TAG} AS rclone
44

55
FROM golang:1.23.8-bookworm AS build
66
COPY go.mod go.sum ./
7-
COPY cmd/ ./cmd/
8-
COPY pkg/ ./pkg/
9-
RUN go build -o /csi-rclone cmd/csi-rclone-plugin/main.go
7+
RUN --mount=type=cache,target=/go/pkg/mod \
8+
go mod download
9+
COPY cmd/ ./cmd
10+
COPY pkg/ ./pkg
11+
RUN --mount=type=cache,target=/root/.cache/go-build \
12+
CGO_ENABLED=1 \
13+
go build -trimpath -buildvcs=false -ldflags='-s' \
14+
-o /csi-rclone ./cmd/csi-rclone-plugin
1015

1116
FROM debian:bookworm-slim
12-
# NOTE: the rclone needs ca-certificates and fuse3 to successfully mount cloud storage
13-
RUN apt-get update && apt-get install -y fuse3 ca-certificates && rm -rf /var/cache/apt/archives /var/lib/apt/lists/*
17+
RUN <<EOT bash
18+
set -ex
19+
apt-get update
20+
apt-get install -y --no-install-recommends ca-certificates fuse3
21+
rm -rf /var/lib/apt/lists/*
22+
EOT
1423
COPY --from=build /csi-rclone /csi-rclone
1524
COPY --from=rclone --chmod=755 /rclone /usr/bin/
16-
ENTRYPOINT ["/csi-rclone"]
25+
26+
ENTRYPOINT ["/csi-rclone"]

deploy/csi-rclone/templates/csi-nodeplugin-rclone.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ spec:
8282
value: {{ .Values.csiNodepluginRclone.rclone.cache.dir | quote }}
8383
- name: CACHE_SIZE
8484
value: {{ .Values.csiNodepluginRclone.rclone.cache.size | quote }}
85+
{{- with .Values.csiNodepluginRclone.rclone.extraEnv }}
86+
{{- if . }}
87+
{{ toYaml . | nindent 8 }}
88+
{{- end }}
89+
{{- end }}
8590
image: {{ .Values.csiNodepluginRclone.rclone.image.repository }}:{{ .Values.csiNodepluginRclone.rclone.image.tag | default .Chart.AppVersion }}
8691
imagePullPolicy: {{ .Values.csiNodepluginRclone.rclone.imagePullPolicy }}
8792
resources:

deploy/csi-rclone/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ csiNodepluginRclone:
4040
add:
4141
- SYS_ADMIN
4242
privileged: true
43+
extraEnv: []
4344
image:
4445
repository: csi-rclone
4546
tag: "latest"

pkg/rclone/rclone.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ type VfsOpt struct {
7676
FilePerms os.FileMode `json:",omitempty"`
7777
ChunkSize string `json:",omitempty"` // if > 0 read files in chunks
7878
ChunkSizeLimit string `json:",omitempty"` // if > ChunkSize double the chunk size after each chunk until reached
79+
ChunkStreams int `json:",omitempty"`
7980
CacheMode string `json:",omitempty"`
8081
CacheMaxAge string `json:",omitempty"`
8182
CacheMaxSize string `json:",omitempty"`

0 commit comments

Comments
 (0)