Skip to content

Commit 1ab51e8

Browse files
fix(helm): Run Dockerfile as uid 1000 (#1274)
Configures a default 1000 user for container to run as. This allows a username to be found when running without the LDAP sidecar or when running as a user not registered in LDAP, e.g. the default 1000 user in the Helm chart/Kyverno policy. As we remove the need for hostNetwork and continue to push for a non-dls_sw scratch area, the container does not require running as a specific user and can run as an arbitrary user with fewer permissions. This fixes problems of [attaching a devcontainer for debugging](https://diamondlightsource.github.io/python-copier-template/main/how-to/debug-in-cluster.html#debugging-in-the-cluster) when running as a non-LDAP user.
1 parent ab3be3d commit 1ab51e8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ RUN sed -i 's/files/ldap files/g' /etc/nsswitch.conf
4646
RUN pip install debugpy
4747
RUN pip install -e .
4848

49+
RUN groupadd -g 1000 blueapi && \
50+
useradd -m -u 1000 -g blueapi blueapi
51+
52+
# Switch to the custom user
53+
USER blueapi
54+
4955
# Alternate entrypoint to allow devcontainer to attach
5056
ENTRYPOINT [ "/bin/bash", "-c", "--" ]
5157
CMD [ "while true; do sleep 30; done;" ]
@@ -75,5 +81,11 @@ RUN sed -i 's/files/ldap files/g' /etc/nsswitch.conf
7581

7682
ENV MPLCONFIGDIR=/tmp/matplotlib
7783

84+
RUN groupadd -g 1000 blueapi && \
85+
useradd -m -u 1000 -g blueapi blueapi
86+
87+
# Switch to the custom user
88+
USER blueapi
89+
7890
ENTRYPOINT ["blueapi"]
7991
CMD ["serve"]

0 commit comments

Comments
 (0)