From d487189a2a59b96017e8e58ff5b44a2b47a50ff4 Mon Sep 17 00:00:00 2001 From: Christian Krakau-Louis Date: Tue, 13 May 2025 11:32:49 +0200 Subject: [PATCH] Refactor Dockerfile to streamline application file copying and remove unnecessary dependencies; add .dockerignore to manage included files. --- .dockerignore | 21 +++++++++++++++++++++ Dockerfile | 11 ++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b5ffcdd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,21 @@ +# Exclude everything by default +* +# Then explicitly include only what we need + +# Core application files +!musicround/ +!migrations/ +!run_migration.py +!run.py +!requirements.txt +!docker-entrypoint.sh +!LICENSE +!favicon.ico + +# Exclude unnecessary files within included directories +**/__pycache__/ +**/*.pyc +**/*.pyo +**/*.pyd +**/.* +musicround/mp3/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index d86b87b..8d3865a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,20 +4,21 @@ FROM python:3.11-slim # Set the working directory to /app WORKDIR /app -# Install system dependencies and Node.js +# Install system dependencies RUN apt-get update && apt-get install -y \ libavcodec-extra \ ffmpeg \ - curl \ - gnupg \ && rm -rf /var/lib/apt/lists/* # Copy requirements first for better caching COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt -# Copy application code -COPY . . +# Copy only necessary application files +# The .dockerignore file ensures we only include what's specified +COPY musicround/ ./musicround/ +COPY migrations/ ./migrations/ +COPY run_migration.py run.py docker-entrypoint.sh LICENSE favicon.ico ./ # Make the entrypoint script executable RUN chmod +x docker-entrypoint.sh