Finalize Docker setup for Aniworld app
This commit is contained in:
34
.dockerignore
Normal file
34
.dockerignore
Normal file
@@ -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
|
||||||
33
Docker/Dockerfile.app
Normal file
33
Docker/Dockerfile.app
Normal file
@@ -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"]
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
services:
|
services:
|
||||||
vpn:
|
vpn:
|
||||||
build: .
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Containerfile
|
||||||
container_name: vpn-wireguard
|
container_name: vpn-wireguard
|
||||||
cap_add:
|
cap_add:
|
||||||
- NET_ADMIN
|
- NET_ADMIN
|
||||||
@@ -12,7 +14,6 @@ services:
|
|||||||
- ./wg0.conf:/etc/wireguard/wg0.conf:ro
|
- ./wg0.conf:/etc/wireguard/wg0.conf:ro
|
||||||
- /lib/modules:/lib/modules:ro
|
- /lib/modules:/lib/modules:ro
|
||||||
ports:
|
ports:
|
||||||
# Expose app's port 8000 to the local network through the VPN container
|
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
environment:
|
environment:
|
||||||
- HEALTH_CHECK_INTERVAL=10
|
- HEALTH_CHECK_INTERVAL=10
|
||||||
@@ -26,12 +27,21 @@ services:
|
|||||||
retries: 3
|
retries: 3
|
||||||
|
|
||||||
app:
|
app:
|
||||||
image: python:3.12-alpine
|
build:
|
||||||
container_name: vpn-app
|
context: ..
|
||||||
# Share the VPN container's network — all outgoing traffic goes through WireGuard
|
dockerfile: Docker/Dockerfile.app
|
||||||
|
container_name: aniworld-app
|
||||||
network_mode: "service:vpn"
|
network_mode: "service:vpn"
|
||||||
depends_on:
|
depends_on:
|
||||||
vpn:
|
vpn:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
# Example: simple HTTP server on port 8000. Replace with your actual app.
|
environment:
|
||||||
command: ["python3", "-m", "http.server", "8000"]
|
- PYTHONUNBUFFERED=1
|
||||||
|
volumes:
|
||||||
|
- app-data:/app/data
|
||||||
|
- app-logs:/app/logs
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
app-data:
|
||||||
|
app-logs:
|
||||||
|
|||||||
Reference in New Issue
Block a user