From a5f8d06ef70960bed4f65fba1d1f5f8e09980cd3 Mon Sep 17 00:00:00 2001 From: Yash Ajgaonkar Date: Wed, 24 Apr 2024 20:57:54 +0530 Subject: [PATCH] Use non-root user in Dockerfile Signed-off-by: Yash Ajgaonkar --- Dockerfile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 633fba1..28c164a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,14 +44,19 @@ RUN go mod download &&\ FROM ${PLATFORM}/alpine:3.15 -# tc - is needed for traffic control and shaping on the sidecar. it is part of the iproute2 +# Creating a non-root user +RUN adduser -D myuser +# tc - is needed for traffic control and shaping on the sidecar. it is part of the iproute2 +# Install necessary packages RUN apk add --no-cache ca-certificates \ iproute2 -# Copy our static executable. +# Switching to the non-root user +USER myuser -COPY --from=gobuilder bin/kubeslice-gw-sidecar . +# Copy our static executable. +COPY --from=gobuilder --chown=myuser:myuser bin/kubeslice-gw-sidecar . EXPOSE 5000