Skip to content

Commit a7055c9

Browse files
committed
change dockerfile to use distroless base image
1 parent 41bba8a commit a7055c9

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Dockerfile

+17-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
1516
ARG BUILDPLATFORM
1617

1718
FROM --platform=$BUILDPLATFORM golang:1.17.2 as builder
@@ -28,10 +29,25 @@ FROM k8s.gcr.io/build-image/debian-base:buster-v1.9.0 as mad-hack
2829
RUN clean-install udev
2930

3031
# Start from Kubernetes Debian base
31-
FROM k8s.gcr.io/build-image/debian-base:buster-v1.9.0
32+
FROM k8s.gcr.io/build-image/debian-base:buster-v1.9.0 as debian
3233
COPY --from=builder /go/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/bin/gce-pd-csi-driver /gce-pd-csi-driver
34+
35+
3336
# Install necessary dependencies
3437
RUN clean-install util-linux e2fsprogs mount ca-certificates udev xfsprogs
38+
39+
FROM gcr.io/distroless/base
40+
COPY --from=builder /go/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/bin/gce-pd-csi-driver /gce-pd-csi-driver
3541
COPY --from=mad-hack /lib/udev/scsi_id /lib/udev_containerized/scsi_id
42+
# COPY --from=debian /lib/xfsprogs/ /lib/xfsprogs_containerized/
43+
# COPY --from=debian /lib/util-linux/ /lib/util-linux_containerized/
44+
45+
3646

3747
ENTRYPOINT ["/gce-pd-csi-driver"]
48+
49+
# Since you're leveraging apt to pull in dependencies, you'd want to use `gcr.io/distroless/base` as the ultimate base because it includes glibc
50+
51+
52+
# COPY --from=builder /lib/x86_64-linux-gnu/libpthread.so.0 /lib/x86_64-linux-gnu/]
53+
# RUN ["/busybox/sh", "-c", "clean-install util-linux e2fsprogs mount ca-certificates udev xfsprogs"]

0 commit comments

Comments
 (0)