Refactor Dockerfile to streamline application file copying and remove unnecessary dependencies; add .dockerignore to manage included files.

This commit is contained in:
Christian Krakau-Louis
2025-05-13 11:32:49 +02:00
parent 0d5cad85e9
commit d487189a2a
2 changed files with 27 additions and 5 deletions
+21
View File
@@ -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/
+6 -5
View File
@@ -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