second server version

This commit is contained in:
2025-09-28 19:24:14 +02:00
parent e2a08d7ab3
commit fa994f7398
69 changed files with 33717 additions and 445 deletions

View File

@@ -1,21 +1,62 @@
# Use an official Python runtime as a parent image
FROM python:3.10
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
# Ensure the directory exists
RUN mkdir -p /app
# Copy the requirements file before copying the app files (for better caching)
# 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 and activate a virtual environment
RUN python -m venv venv && \
. venv/bin/activate && \
pip install --no-cache-dir -r requirements.txt
# Create necessary directories
RUN mkdir -p /app/data /app/logs /app/backups /app/temp && \
chown -R aniworld:aniworld /app
# Run the application using the virtual environment
CMD ["/bin/bash", "-c", "source venv/bin/activate && python main.py"]
# 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"]