From d8248be67d77b2e9119b5a23c6a7424488dc3992 Mon Sep 17 00:00:00 2001 From: Lukas Date: Sun, 22 Feb 2026 19:57:46 +0100 Subject: [PATCH] Finalize Docker setup for Aniworld app --- .dockerignore | 34 ++++++++++++++++++++++++++++++++++ Docker/Dockerfile.app | 33 +++++++++++++++++++++++++++++++++ Docker/podman-compose.yml | 24 +++++++++++++++++------- 3 files changed, 84 insertions(+), 7 deletions(-) create mode 100644 .dockerignore create mode 100644 Docker/Dockerfile.app diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..69ffbd9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,34 @@ +__pycache__/ +*.pyc +*.pyo +*.egg-info/ +.git/ +.github/ +.gitignore +.vscode/ +.vs/ +.idea/ +.mypy_cache/ +.pytest_cache/ +.coverage +.env +*.log + +# Docker files (not needed inside the image) +Docker/ + +# Test and dev files +tests/ +Temp/ +test_data/ +docs/ +diagrams/ + +# Runtime data (mounted as volumes) +data/aniworld.db +data/config_backups/ +logs/ + +# Frontend tooling +node_modules/ +package.json diff --git a/Docker/Dockerfile.app b/Docker/Dockerfile.app new file mode 100644 index 0000000..1a7df53 --- /dev/null +++ b/Docker/Dockerfile.app @@ -0,0 +1,33 @@ +FROM python:3.12-slim + +WORKDIR /app + +# Install system dependencies for compiled Python packages +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + gcc \ + g++ \ + libffi-dev \ + && rm -rf /var/lib/apt/lists/* + +# Install Python dependencies (cached layer) +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the full application +COPY src/ ./src/ +COPY run_server.py . +COPY pyproject.toml . +COPY data/config.json ./data/config.json + +# Create runtime directories +RUN mkdir -p /app/data/config_backups /app/logs + +EXPOSE 8000 + +ENV PYTHONUNBUFFERED=1 +ENV PYTHONPATH=/app + +# Bind to 0.0.0.0 so the app is reachable from the VPN container's network +CMD ["python", "-m", "uvicorn", "src.server.fastapi_app:app", \ + "--host", "0.0.0.0", "--port", "8000"] diff --git a/Docker/podman-compose.yml b/Docker/podman-compose.yml index ae7abab..8ee5520 100644 --- a/Docker/podman-compose.yml +++ b/Docker/podman-compose.yml @@ -1,6 +1,8 @@ services: vpn: - build: . + build: + context: . + dockerfile: Containerfile container_name: vpn-wireguard cap_add: - NET_ADMIN @@ -12,7 +14,6 @@ services: - ./wg0.conf:/etc/wireguard/wg0.conf:ro - /lib/modules:/lib/modules:ro ports: - # Expose app's port 8000 to the local network through the VPN container - "8000:8000" environment: - HEALTH_CHECK_INTERVAL=10 @@ -26,12 +27,21 @@ services: retries: 3 app: - image: python:3.12-alpine - container_name: vpn-app - # Share the VPN container's network — all outgoing traffic goes through WireGuard + build: + context: .. + dockerfile: Docker/Dockerfile.app + container_name: aniworld-app network_mode: "service:vpn" depends_on: vpn: condition: service_healthy - # Example: simple HTTP server on port 8000. Replace with your actual app. - command: ["python3", "-m", "http.server", "8000"] + environment: + - PYTHONUNBUFFERED=1 + volumes: + - app-data:/app/data + - app-logs:/app/logs + restart: unless-stopped + +volumes: + app-data: + app-logs: