From a2c1fbe0c80b6bafa1e8579f74da7e6f8f241126 Mon Sep 17 00:00:00 2001 From: oguzhankoral Date: Tue, 24 Oct 2023 18:40:44 +0300 Subject: [PATCH] Switch user to run --- Dockerfile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5a71f4d..d2e9a64 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,9 @@ ENV DEBIAN_FRONTEND=noninteractive ENV TZ=Europe/Istanbul ENV VM_PROJECT_DIR=/opt/openfoam9 +# Create a non-root user +RUN useradd -ms /bin/bash openfoamRunner + RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN apt update @@ -15,11 +18,19 @@ RUN apt-get update RUN apt-get -y --no-install-recommends install openfoam9 RUN echo "source /opt/openfoam9/etc/bashrc" >> /root/.bashrc +RUN echo "source /opt/openfoam9/etc/bashrc" >> /home/openfoamRunner/.bashrc RUN pip install poetry +# Change the ownership of your project directory to the non-root user +RUN chown -R openfoamRunner:openfoamRunner $VM_PROJECT_DIR + +USER openfoamRunner + COPY . . -RUN poetry export -f requirements.txt --output requirements.txt && pip3 install -r requirements.txt +RUN poetry export -f requirements.txt --output /home/openfoamRunner/requirements.txt && pip3 install -r /home/openfoamRunner/requirements.txt + +CMD ["/bin/bash"] ### POST-COMPILE (WIP) ###