Skip to content

Commit

Permalink
fix(review/1): non-root user in runtime
Browse files Browse the repository at this point in the history
Signed-off-by: Mateusz Urbanek <[email protected]>
  • Loading branch information
shanduur-akamai committed Nov 22, 2023
1 parent 0aba70d commit cbe3db7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ ARG TOOLCHAIN_VERSION=1.21
# First stage: building the driver executable.
FROM docker.io/library/golang:${TOOLCHAIN_VERSION} as builder

# Set the working directory.
WORKDIR /work

# Prepare dir so it can be copied over to runtime layer.
RUN mkdir -p /var/lib/cosi

# Copy the Go Modules manifests.
COPY go.mod go.mod
COPY go.sum go.sum
Expand Down Expand Up @@ -50,11 +54,18 @@ RUN make build
# Second stage: building final environment for running the executable.
FROM gcr.io/distroless/static-debian11:latest AS runtime

COPY --from=builder /work/bin/linode-cosi-driver /usr/bin/linode-cosi-driver
# Copy the executable.
COPY --from=builder --chown=65532:65532 /work/bin/linode-cosi-driver /usr/bin/linode-cosi-driver

# Copy the volume directory with correct permissions, so driver can bind a socket there.
COPY --from=builder --chown=65532:65532 /var/lib/cosi /var/lib/cosi

# Set volume mount point for app socket.
VOLUME [ "/var/lib/cosi" ]

# Set the final UID:GID to non-root user.
USER 65532:65532

# Disable healthcheck.
HEALTHCHECK NONE

Expand Down

0 comments on commit cbe3db7

Please sign in to comment.