Skip to content

Commit 6c0706a

Browse files
Switch to a non-root user in docker (#247)
1 parent 58a7eaf commit 6c0706a

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

app/dl_control_api/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ WORKDIR /src/metapkg
2222
RUN poetry export --only app_dl_os_control_api --without-hashes --format=requirements.txt > requirements.txt
2323
RUN pip install -r requirements.txt
2424

25+
# Setting up the runtime user
26+
ARG USER=app
27+
ARG GID=1000
28+
ARG UID=1000
29+
RUN groupadd -r -g ${GID} ${USER} && \
30+
useradd -mr -g ${USER} -u ${UID} -s /bin/bash ${USER}
31+
USER ${USER}
32+
2533
EXPOSE 8080
2634

2735
ENTRYPOINT ["/etc/service/dl_api/run"]

app/dl_data_api/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ WORKDIR /src/metapkg
2626
RUN poetry export --only app_dl_os_data_api --without-hashes --format=requirements.txt > requirements.txt
2727
RUN pip install -r requirements.txt
2828

29+
# Setting up the runtime user
30+
ARG USER=app
31+
ARG GID=1000
32+
ARG UID=1000
33+
RUN groupadd -r -g ${GID} ${USER} && \
34+
useradd -mr -g ${USER} -u ${UID} -s /bin/bash ${USER}
35+
USER ${USER}
36+
2937
EXPOSE 8080
3038

3139
ENTRYPOINT ["/etc/service/dl_api/run"]

0 commit comments

Comments
 (0)