76 lines
1.5 KiB
Docker
76 lines
1.5 KiB
Docker
# Simple Dockerfile using requirements.txt instead of Poetry
|
|
FROM python:3.11-slim as base
|
|
|
|
# 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 \
|
|
build-essential \
|
|
curl \
|
|
git \
|
|
ffmpeg \
|
|
libmagic1 \
|
|
libpq-dev \
|
|
pkg-config \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy requirements first for better caching
|
|
COPY requirements.txt ./requirements.txt
|
|
|
|
# Development stage
|
|
FROM base as development
|
|
|
|
# Install dependencies
|
|
RUN pip install -r requirements.txt
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Set development environment
|
|
ENV PYTHONPATH=/app
|
|
ENV DEBUG=true
|
|
|
|
# Expose ports
|
|
EXPOSE 15100 9090
|
|
|
|
# Default command for development
|
|
CMD ["python", "start_my_network.py"]
|
|
|
|
# Production stage
|
|
FROM base as production
|
|
|
|
# Install dependencies
|
|
RUN pip install -r requirements.txt
|
|
|
|
# Create non-root user
|
|
RUN groupadd -r appuser && useradd -r -g appuser appuser
|
|
|
|
# Copy application code
|
|
COPY --chown=appuser:appuser . .
|
|
|
|
# Create necessary directories
|
|
RUN mkdir -p /app/data /app/logs && \
|
|
chown -R appuser:appuser /app/data /app/logs
|
|
|
|
# Set production environment
|
|
ENV PYTHONPATH=/app
|
|
ENV DEBUG=false
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
|
CMD curl -f http://localhost:15100/health || exit 1
|
|
|
|
# Switch to non-root user
|
|
USER appuser
|
|
|
|
# Expose ports
|
|
EXPOSE 15100 9090
|
|
|
|
# Default command
|
|
CMD ["python", "start_my_network.py"] |