Skip to content

Commit 269335e

Browse files
authored
Uses scratch image for all base images
1 parent 99693ea commit 269335e

File tree

7 files changed

+38
-15
lines changed

7 files changed

+38
-15
lines changed

BUILD.md

+6
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ Default: `trident-operator`
166166

167167
Trident operator image name used to create operator image tag.
168168

169+
`TRIDENT_DEPS_IMAGE`
170+
171+
Default: See "DEPS_IMAGE" in ./Dockerfile
172+
173+
Image used to get dependencies such as NFS.
174+
169175
## Makefile Targets
170176

171177
### Build Targets

Dockerfile

+20-8
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
11
ARG ARCH=amd64
2+
# Image for dependencies such as NFS binaries
3+
ARG DEPS_IMAGE=alpine:3
24

3-
FROM --platform=linux/${ARCH} alpine:latest AS baseimage
5+
FROM --platform=linux/${ARCH} $DEPS_IMAGE AS deps
46

5-
RUN apk add nfs-utils
7+
ARG DEPS_IMAGE
68

7-
#Get the mount.nfs4 dependency
9+
# Installs nfs-utils based on DEPS_IMAGE
10+
RUN --mount=type=secret,id=activation_key,env=ACTIVATION_KEY \
11+
--mount=type=secret,id=organization,env=ORGANIZATION \
12+
function unregister() { subscription-manager unregister || true; }; trap unregister EXIT; \
13+
if [[ $DEPS_IMAGE =~ "alpine" ]]; \
14+
then apk add nfs-utils; \
15+
else subscription-manager register --activationkey $ACTIVATION_KEY --org $ORGANIZATION && \
16+
yum install --repo=rhel-9-*-baseos-rpms -y nfs-utils; \
17+
fi
18+
19+
# Get the mount.nfs4 dependency
820
RUN ldd /sbin/mount.nfs4 | tr -s '[:space:]' '\n' | grep '^/' | xargs -I % sh -c 'mkdir -p /nfs-deps/$(dirname %) && cp -L % /nfs-deps/%'
921
RUN ldd /sbin/mount.nfs | tr -s '[:space:]' '\n' | grep '^/' | xargs -I % sh -c 'mkdir -p /nfs-deps/$(dirname %) && cp -r -u -L % /nfs-deps/%'
1022

11-
FROM --platform=linux/${ARCH} gcr.io/distroless/static@sha256:69830f29ed7545c762777507426a412f97dad3d8d32bae3e74ad3fb6160917ea
23+
FROM scratch
1224

1325
LABEL maintainers="The NetApp Trident Team" \
1426
app="trident.netapp.io" \
1527
description="Trident Storage Orchestrator"
1628

17-
COPY --from=baseimage /bin/mount /bin/umount /bin/
18-
COPY --from=baseimage /sbin/mount.nfs /sbin/mount.nfs4 /sbin/
19-
COPY --from=baseimage /etc/netconfig /etc/
20-
COPY --from=baseimage /nfs-deps/ /
29+
COPY --from=deps /bin/mount /bin/umount /bin/
30+
COPY --from=deps /sbin/mount.nfs /sbin/mount.nfs4 /sbin/
31+
COPY --from=deps /etc/netconfig /etc/
32+
COPY --from=deps /nfs-deps/ /
2133

2234
ARG BIN=trident_orchestrator
2335
ARG CLI_BIN=tridentctl

Dockerfile.Windows

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
ARG WINDOWS_VERSION
2-
ARG ARCH
1+
ARG WINDOWS_VERSION=ltsc2022
2+
ARG ARCH=amd64
33

4-
FROM --platform=windows/${ARCH} mcr.microsoft.com/windows/servercore:${WINDOWS_VERSION} as add_on
4+
FROM --platform=windows/${ARCH} mcr.microsoft.com/windows/servercore:${WINDOWS_VERSION} AS add_on
55
FROM --platform=windows/${ARCH} mcr.microsoft.com/windows/nanoserver:${WINDOWS_VERSION}
66

77
ARG BIN=trident_orchestrator.exe

Makefile

+6
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ DEFAULT_AUTOSUPPORT_IMAGE ?=
9191
# DEFAULT_ACP_IMAGE override the default acp image in tridentctl and operator
9292
DEFAULT_ACP_IMAGE ?=
9393

94+
# TRIDENT_DEPS_IMAGE sets the image used by the Trident dockerfile to install dependencies such as NFS
95+
TRIDENT_DEPS_IMAGE ?=
96+
9497
# Constants
9598
ALL_PLATFORMS = linux/amd64 linux/arm64 windows/amd64/ltsc2022 windows/amd64/ltsc2019 darwin/amd64
9699
DEFAULT_REGISTRY = docker.io/netapp
@@ -241,6 +244,9 @@ docker_build_linux = $1 build \
241244
--build-arg NODE_PREP_BIN=$(call binary_path,node_prep,$2) \
242245
--build-arg CHWRAP_BIN=$(call binary_path,chwrap.tar,$2) \
243246
--build-arg SYSWRAP_BIN=${call binary_path,syswrap,$2} \
247+
$(if $(TRIDENT_DEPS_IMAGE),--build-arg DEPS_IMAGE=$(TRIDENT_DEPS_IMAGE)) \
248+
--secret id=activation_key,env=ACTIVATION_KEY \
249+
--secret id=organization,env=ORGANIZATION \
244250
--tag $3 \
245251
--rm \
246252
$(if $(findstring $(DOCKER_BUILDX_BUILD_CLI),$1),--builder trident-builder) \

contrib/docker/plugin/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM busybox:uclibc as busybox
22

3-
FROM gcr.io/distroless/static@sha256:69830f29ed7545c762777507426a412f97dad3d8d32bae3e74ad3fb6160917ea
3+
FROM scratch
44

55
LABEL maintainers="The NetApp Trident Team" \
66
app="trident.netapp.io" \

operator/Dockerfile

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
ARG ARCH=amd64
2-
3-
FROM --platform=linux/${ARCH} gcr.io/distroless/static@sha256:69830f29ed7545c762777507426a412f97dad3d8d32bae3e74ad3fb6160917ea
1+
FROM scratch
42

53
LABEL maintainers="The NetApp Trident Team" \
64
app="trident-operator.netapp.io" description="Trident Operator"

utils/devices/devices.go

+1
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ func (c *Client) ScanTargetLUN(ctx context.Context, deviceAddresses []models.Scs
855855
"scanFile": filename,
856856
"host": deviceAddress.Host,
857857
}).Debug("Invoked SCSI scan for host.")
858+
858859
}
859860

860861
return nil

0 commit comments

Comments
 (0)