From 9f05650f58d28f8c3d0154933565715666cba45a Mon Sep 17 00:00:00 2001 From: Paillat Date: Thu, 2 Nov 2023 17:09:43 +0100 Subject: [PATCH] Update Dockerfile --- Dockerfile | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index f2b3963..7a6a41f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,28 @@ -# For more information, please refer to https://aka.ms/vscode-docker-python FROM python:3.11-bookworm -# Turns off buffering for easier container logging -ENV PYTHONUNBUFFERED=1 -# Turns off pyc files + +# Keeps Python from generating .pyc files in the container ENV PYTHONDONTWRITEBYTECODE=1 -# Install pip requirements -WORKDIR /Botator -RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /Botator +# Turns off buffering for easier container logging +ENV PYTHONUNBUFFERED=1 + + +# we move to the app folder and run the pip install command +WORKDIR /app + +# we copy just the requirements.txt first to leverage Docker cache COPY requirements.txt . + +# Install pip requirements RUN pip install -r requirements.txt -COPY . . + + # Creates a non-root user with an explicit UID and adds permission to access the /app folder +RUN adduser -u 5574 --disabled-password --gecos "" appuser && chown -R appuser /app USER appuser -CMD ["python", "main.py"] \ No newline at end of file + +# We copy the rest of the codebase into the image +COPY . /app + +# We run the application +CMD ["python", "main.py"]