From ba9bc2c3b95766f0b0eedcf47b8b7c2f40b9b3ba Mon Sep 17 00:00:00 2001 From: catborise Date: Thu, 24 Sep 2026 22:41:34 +0300 Subject: [PATCH] perf(docker): optimize dependency layer caching and update dockerignore - Copy requirements.txt before application source to leverage Docker layer caching - Expand .dockerignore to exclude local venv, cache files, logs, and .env files --- .dockerignore | 59 +++++++++++++++++++++++++++++++++++++++------------ Dockerfile | 12 ++++++----- 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/.dockerignore b/.dockerignore index 9dca038..05e5f58 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,25 +1,58 @@ -**/__pycache__ -**/.classpath -**/.dockerignore -**/.env +# Git **/.git **/.gitignore + +# Python bytecode & cache +**/__pycache__ +**/*.py[cod] +**/*$py.class +**/.pytest_cache +**/.coverage +**/htmlcov + +# Virtual environments & environment files +**/venv* +**/.venv* +**/env* +**/.env* + +# Local databases and runtime data +**/*.sqlite3* +**/*.log +**/console/cert.pem* +**/dhcpd.* + +# IDEs and OS +**/.idea +**/.vscode +**/.vs +**/.DS_Store +**/.classpath **/.project **/.settings **/.toolstarget -**/.vs -**/.vscode **/*.*proj.user **/*.dbmdl **/*.jfm -**/azds.yaml -**/bin -**/charts -**/docker-compose* +**/.vagrant + +# Docker and CI +**/.dockerignore **/Dockerfile* +**/docker-compose* +**/azds.yaml +**/charts +**/secrets.dev.yaml +**/values.dev.yaml + +# Node / frontend build leftovers **/node_modules **/npm-debug.log **/obj -**/secrets.dev.yaml -**/values.dev.yaml -README.md \ No newline at end of file +**/bin + +# Documentation / metadata +README.md +AGENTS.md +CODEBASE_OVERVIEW.md +DEPENDENCY_UPGRADE_PLAN.md \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index e246127..28a568e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,18 +27,20 @@ RUN apt-get update -qqy \ libsasl2-modules \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -COPY . /srv/webvirtcloud -RUN chown -R www-data:www-data /srv/webvirtcloud - # Setup webvirtcloud WORKDIR /srv/webvirtcloud + +# Install Python dependencies first to leverage Docker layer caching +COPY conf/requirements.txt conf/requirements.txt RUN python3 -m venv venv && \ . venv/bin/activate && \ pip3 install -U pip && \ pip3 install wheel && \ pip3 install -r conf/requirements.txt && \ - pip3 cache purge && \ - chown -R www-data:www-data /srv/webvirtcloud + pip3 cache purge + +# Copy application source +COPY . /srv/webvirtcloud RUN . venv/bin/activate && \ python3 manage.py makemigrations && \