new folder structure
This commit is contained in:
62
docker/Dockerfile
Normal file
62
docker/Dockerfile
Normal file
@@ -0,0 +1,62 @@
|
||||
# Use an official Python runtime as a parent image
|
||||
FROM python:3.11-slim
|
||||
|
||||
# Set environment variables
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PIP_NO_CACHE_DIR=1 \
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=1
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
gcc \
|
||||
sqlite3 \
|
||||
curl \
|
||||
wget \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create app user for security
|
||||
RUN groupadd -r aniworld && useradd -r -g aniworld aniworld
|
||||
|
||||
# Set the working directory inside the container
|
||||
WORKDIR /app
|
||||
|
||||
# Copy requirements first for better Docker layer caching
|
||||
COPY requirements.txt .
|
||||
|
||||
# Install Python dependencies
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy application code
|
||||
COPY src/ ./src/
|
||||
COPY main.py .
|
||||
COPY Loader.py .
|
||||
COPY *.md ./
|
||||
|
||||
# Create necessary directories
|
||||
RUN mkdir -p /app/data /app/logs /app/backups /app/temp && \
|
||||
chown -R aniworld:aniworld /app
|
||||
|
||||
# Copy configuration and scripts (if they exist)
|
||||
COPY docker ./docker
|
||||
|
||||
# Set default environment variables
|
||||
ENV ANIME_DIRECTORY="/app/data" \
|
||||
DATABASE_PATH="/app/data/aniworld.db" \
|
||||
LOG_LEVEL="INFO" \
|
||||
FLASK_ENV="production" \
|
||||
WEB_HOST="0.0.0.0" \
|
||||
WEB_PORT="5000"
|
||||
|
||||
# Expose the web server port
|
||||
EXPOSE 5000
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:5000/api/health/system || exit 1
|
||||
|
||||
# Switch to non-root user
|
||||
USER aniworld
|
||||
|
||||
# Default command - run web server
|
||||
CMD ["python", "src/server/app.py"]
|
||||
39
docker/Dockerfile.dev
Normal file
39
docker/Dockerfile.dev
Normal file
@@ -0,0 +1,39 @@
|
||||
# Development Dockerfile
|
||||
FROM python:3.11-slim
|
||||
|
||||
# Set environment variables
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
FLASK_ENV=development \
|
||||
FLASK_DEBUG=1
|
||||
|
||||
# Set work directory
|
||||
WORKDIR /app
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
gcc \
|
||||
g++ \
|
||||
libc6-dev \
|
||||
libffi-dev \
|
||||
libssl-dev \
|
||||
curl \
|
||||
git \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install Python dependencies
|
||||
COPY requirements.txt requirements-dev.txt ./
|
||||
RUN pip install --no-cache-dir -r requirements-dev.txt
|
||||
|
||||
# Copy project
|
||||
COPY . .
|
||||
|
||||
# Create necessary directories
|
||||
RUN mkdir -p data/database data/logs data/cache data/temp/downloads
|
||||
|
||||
# Expose port
|
||||
EXPOSE 5000
|
||||
|
||||
# Development command
|
||||
CMD ["python", "src/server/app.py"]
|
||||
52
docker/docker-compose.dev.yml
Normal file
52
docker/docker-compose.dev.yml
Normal file
@@ -0,0 +1,52 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: docker/Dockerfile.dev
|
||||
ports:
|
||||
- "5000:5000"
|
||||
volumes:
|
||||
- ../src:/app/src
|
||||
- ../data:/app/data
|
||||
- ../tests:/app/tests
|
||||
- ../config:/app/config
|
||||
environment:
|
||||
- FLASK_ENV=development
|
||||
- FLASK_DEBUG=1
|
||||
- DATABASE_URL=sqlite:///data/database/anime.db
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
depends_on:
|
||||
- redis
|
||||
networks:
|
||||
- aniworld-dev
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
ports:
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
networks:
|
||||
- aniworld-dev
|
||||
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ../docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- ../src/server/web/static:/var/www/static:ro
|
||||
depends_on:
|
||||
- app
|
||||
networks:
|
||||
- aniworld-dev
|
||||
|
||||
volumes:
|
||||
redis_data:
|
||||
|
||||
|
||||
networks:
|
||||
aniworld-dev:
|
||||
driver: bridge
|
||||
167
docker/docker-compose.yml
Normal file
167
docker/docker-compose.yml
Normal file
@@ -0,0 +1,167 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
# AniWorld Web Application
|
||||
aniworld-web:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: aniworld-web
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- ANIME_DIRECTORY=/app/data/anime
|
||||
- DATABASE_PATH=/app/data/aniworld.db
|
||||
- LOG_LEVEL=INFO
|
||||
- FLASK_ENV=production
|
||||
- WEB_HOST=0.0.0.0
|
||||
- WEB_PORT=5000
|
||||
- MASTER_PASSWORD=${MASTER_PASSWORD:-admin123}
|
||||
volumes:
|
||||
- anime_data:/app/data
|
||||
- anime_logs:/app/logs
|
||||
- anime_backups:/app/backups
|
||||
- anime_temp:/app/temp
|
||||
- ${ANIME_DIRECTORY:-./data}:/app/data/anime
|
||||
ports:
|
||||
- "${WEB_PORT:-5000}:5000"
|
||||
networks:
|
||||
- aniworld
|
||||
- vpn
|
||||
depends_on:
|
||||
- redis
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:5000/api/health/system"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
# Redis for caching and session management
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: aniworld-redis
|
||||
restart: unless-stopped
|
||||
command: redis-server --appendonly yes
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
networks:
|
||||
- aniworld
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 30s
|
||||
timeout: 3s
|
||||
retries: 3
|
||||
|
||||
# Nginx reverse proxy
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
container_name: aniworld-nginx
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${HTTP_PORT:-80}:80"
|
||||
- "${HTTPS_PORT:-443}:443"
|
||||
volumes:
|
||||
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- ./docker/nginx/ssl:/etc/nginx/ssl:ro
|
||||
- nginx_logs:/var/log/nginx
|
||||
networks:
|
||||
- aniworld
|
||||
depends_on:
|
||||
- aniworld-web
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
||||
# Monitoring with Prometheus (optional)
|
||||
prometheus:
|
||||
image: prom/prometheus
|
||||
container_name: aniworld-prometheus
|
||||
restart: unless-stopped
|
||||
command:
|
||||
- '--config.file=/etc/prometheus/prometheus.yml'
|
||||
- '--storage.tsdb.path=/prometheus'
|
||||
- '--web.console.libraries=/etc/prometheus/console_libraries'
|
||||
- '--web.console.templates=/etc/prometheus/consoles'
|
||||
- '--storage.tsdb.retention.time=200h'
|
||||
- '--web.enable-lifecycle'
|
||||
volumes:
|
||||
- ./docker/prometheus:/etc/prometheus
|
||||
- prometheus_data:/prometheus
|
||||
networks:
|
||||
- aniworld
|
||||
profiles:
|
||||
- monitoring
|
||||
|
||||
# Grafana for monitoring dashboards (optional)
|
||||
grafana:
|
||||
image: grafana/grafana
|
||||
container_name: aniworld-grafana
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}
|
||||
volumes:
|
||||
- grafana_data:/var/lib/grafana
|
||||
- ./docker/grafana/provisioning:/etc/grafana/provisioning
|
||||
ports:
|
||||
- "${GRAFANA_PORT:-3000}:3000"
|
||||
networks:
|
||||
- aniworld
|
||||
depends_on:
|
||||
- prometheus
|
||||
profiles:
|
||||
- monitoring
|
||||
|
||||
# VPN/Network services (existing)
|
||||
wireguard:
|
||||
container_name: aniworld-wireguard
|
||||
image: jordanpotter/wireguard
|
||||
user: "1013:1001"
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
- SYS_MODULE
|
||||
sysctls:
|
||||
net.ipv4.conf.all.src_valid_mark: 1
|
||||
volumes:
|
||||
- ${WG_CONFIG_PATH:-/server_aniworld/wg0.conf}:/etc/wireguard/wg0.conf
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- vpn
|
||||
profiles:
|
||||
- vpn
|
||||
|
||||
# Network test utility
|
||||
curl:
|
||||
image: curlimages/curl
|
||||
command: ifconfig.io
|
||||
user: "1013:1001"
|
||||
network_mode: service:wireguard
|
||||
depends_on:
|
||||
- wireguard
|
||||
profiles:
|
||||
- vpn
|
||||
|
||||
networks:
|
||||
aniworld:
|
||||
driver: bridge
|
||||
vpn:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
anime_data:
|
||||
driver: local
|
||||
anime_logs:
|
||||
driver: local
|
||||
anime_backups:
|
||||
driver: local
|
||||
anime_temp:
|
||||
driver: local
|
||||
redis_data:
|
||||
driver: local
|
||||
nginx_logs:
|
||||
driver: local
|
||||
prometheus_data:
|
||||
driver: local
|
||||
grafana_data:
|
||||
driver: local
|
||||
Reference in New Issue
Block a user