62 lines
1.5 KiB
Docker
62 lines
1.5 KiB
Docker
# 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"] |