-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add non-root user to container image
- Loading branch information
1 parent
936f68e
commit 8819ea2
Showing
2 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,13 +21,25 @@ RUN go install \ | |
-ldflags="-X main.gitDescribe=$(git -C /go/src/github.com/ROCm/k8s-device-plugin/ describe --always --long --dirty)" | ||
|
||
FROM alpine:3.20.3 | ||
|
||
ARG USERNAME=amdgpu | ||
ARG USER_UID=1000 | ||
ARG USER_GID=$USER_UID | ||
|
||
LABEL \ | ||
org.opencontainers.image.source="https://github.com/ROCm/k8s-device-plugin" \ | ||
org.opencontainers.image.authors="Kenny Ho <[email protected]>" \ | ||
org.opencontainers.image.vendor="Advanced Micro Devices, Inc." \ | ||
org.opencontainers.image.licenses="Apache-2.0" | ||
|
||
RUN apk --no-cache add ca-certificates libdrm | ||
RUN apk --no-cache add hwloc --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community | ||
WORKDIR /root/ | ||
|
||
RUN addgroup --gid "$USER_GID" "$USERNAME" \ | ||
&& adduser --disabled-password --gecos "" --uid "$USER_UID" --ingroup "$USERNAME" "$USERNAME" | ||
|
||
USER $USERNAME | ||
|
||
WORKDIR /home/$USERNAME/ | ||
COPY --from=0 /go/bin/k8s-device-plugin . | ||
CMD ["./k8s-device-plugin", "-logtostderr=true", "-stderrthreshold=INFO", "-v=5"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,12 +20,23 @@ RUN go install \ | |
-ldflags="-X main.gitDescribe=$(git -C /go/src/github.com/ROCm/k8s-device-plugin/ describe --always --long --dirty)" | ||
|
||
FROM alpine:3.20.3 | ||
|
||
ARG USERNAME=amdgpu | ||
ARG USER_UID=1000 | ||
ARG USER_GID=$USER_UID | ||
|
||
LABEL \ | ||
org.opencontainers.image.source="https://github.com/ROCm/k8s-device-plugin" \ | ||
org.opencontainers.image.authors="Kenny Ho <[email protected]>" \ | ||
org.opencontainers.image.vendor="Advanced Micro Devices, Inc." \ | ||
org.opencontainers.image.licenses="Apache-2.0" | ||
RUN apk --no-cache add ca-certificates libdrm | ||
WORKDIR /root/ | ||
|
||
RUN addgroup --gid "$USER_GID" "$USERNAME" \ | ||
&& adduser --disabled-password --gecos "" --uid "$USER_UID" --ingroup "$USERNAME" "$USERNAME" | ||
|
||
USER $USERNAME | ||
|
||
WORKDIR /home/$USERNAME/ | ||
COPY --from=0 /go/bin/k8s-node-labeller . | ||
CMD ["./k8s-node-labeller"] |