Skip to content

Commit 83ccdb2

Browse files
authored
Update dockerfile to build and run as non root user (#85)
1 parent b5778b1 commit 83ccdb2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Dockerfile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
# since we need some advance binaries for things like pillow and ffmpeg.
33
FROM alpine:3.20.0
44

5-
# We will base ourselves in root, becuase why not.
6-
WORKDIR /root
5+
RUN adduser -Ss /bin/bash app -h /app -g root -u 1001
6+
7+
WORKDIR /app
78

89
# Define some user vars we will use for the image.
910
# These are read in the docker_octoeverywhere module, so they must not change!
10-
ENV USER=root
11-
ENV REPO_DIR=/root/octoeverywhere
12-
ENV VENV_DIR=/root/octoeverywhere-env
11+
ENV USER=app
12+
ENV REPO_DIR=/app/octoeverywhere
13+
ENV VENV_DIR=/app/octoeverywhere-env
1314
# This is a special dir that the user MUST mount to the host, so that the data is persisted.
1415
# If this is not mounted, the printer will need to be re-linked everytime the container is remade.
1516
ENV DATA_DIR=/data/
@@ -36,7 +37,10 @@ RUN ${VENV_DIR}/bin/pip3 install --require-virtualenv --no-cache-dir -q -r ${REP
3637
RUN apk add zstd
3738
RUN ${VENV_DIR}/bin/pip3 install --require-virtualenv --no-cache-dir -q "zstandard>=0.21.0,<0.23.0"
3839

40+
# Ensure directories have correct ownership. Having the group set to root(0) and writable by group will allow this to run on openshift
41+
RUN chown -R 1001:0 /app && chmod -R g+wx /app
42+
3943
# For docker, we use our docker_octoeverywhere host to handle the runtime setup and launch of the serivce.
4044
WORKDIR ${REPO_DIR}
4145
# Use the full path to the venv, we msut use this [] notation for our ctlc handler to work in the contianer
42-
ENTRYPOINT ["/root/octoeverywhere-env/bin/python", "-m", "docker_octoeverywhere"]
46+
ENTRYPOINT ["/app/octoeverywhere-env/bin/python", "-m", "docker_octoeverywhere"]

0 commit comments

Comments
 (0)