From ba77b6741adfaf030ad3ed0581ecc73a52aa1d67 Mon Sep 17 00:00:00 2001 From: Liam Steckler Date: Sat, 11 Jan 2025 10:33:13 -0800 Subject: [PATCH 1/3] Initial Dockerfile --- .dockerignore | 27 +++++++++++++++++++++++++++ Dockerfile | 23 +++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..0b1e1e7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,27 @@ +**/__pycache__ +**/.venv +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/bin +**/charts +**/docker-compose* +**/compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ab89d79 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +# For more information, please refer to https://aka.ms/vscode-docker-python +FROM python:3-slim + +# Keeps Python from generating .pyc files in the container +ENV PYTHONDONTWRITEBYTECODE=1 + +# Turns off buffering for easier container logging +ENV PYTHONUNBUFFERED=1 + +# Install pip requirements +COPY requirements.txt . +RUN python -m pip install -r requirements.txt + +WORKDIR /app +COPY . /app + +# Creates a non-root user with an explicit UID and adds permission to access the /app folder +# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers +RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app +USER appuser + +# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug +CMD ["python", "scl.py"] -- 2.45.3 From d9c589e9c5f7e0d491b2a387b8a5180efc02eabb Mon Sep 17 00:00:00 2001 From: Liam Steckler Date: Sat, 11 Jan 2025 11:15:11 -0800 Subject: [PATCH 2/3] Move to full python:3 as base --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ab89d79..6c95cea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # For more information, please refer to https://aka.ms/vscode-docker-python -FROM python:3-slim +FROM python:3 # Keeps Python from generating .pyc files in the container ENV PYTHONDONTWRITEBYTECODE=1 -- 2.45.3 From adb34c8869ee54be9aec49dc1ff02914dad4b7ab Mon Sep 17 00:00:00 2001 From: Liam Steckler Date: Sat, 11 Jan 2025 11:58:05 -0800 Subject: [PATCH 3/3] Use uv --- Dockerfile | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6c95cea..8cbb569 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,21 @@ -# For more information, please refer to https://aka.ms/vscode-docker-python -FROM python:3 +FROM python:3 AS build -# Keeps Python from generating .pyc files in the container -ENV PYTHONDONTWRITEBYTECODE=1 - -# Turns off buffering for easier container logging -ENV PYTHONUNBUFFERED=1 - -# Install pip requirements -COPY requirements.txt . -RUN python -m pip install -r requirements.txt +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ WORKDIR /app -COPY . /app +RUN uv venv + +COPY requirements.txt . +RUN uv pip install --system -r requirements.txt + +# Copy the project into the intermediate image +ADD . /app + +FROM python:3-slim +# Copy the environment, but not the source code +COPY --from=build --chown=app:app /app/.venv /app/.venv -# Creates a non-root user with an explicit UID and adds permission to access the /app folder -# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app USER appuser -# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug -CMD ["python", "scl.py"] +CMD ["python", "scl.py"] \ No newline at end of file -- 2.45.3