29 Zeilen
683 B
Docker
29 Zeilen
683 B
Docker
FROM python:3.11-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
gcc \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy requirements first for better caching
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application code
|
|
COPY . .
|
|
|
|
# Create non-root user
|
|
RUN useradd -m -u 1000 analytics && chown -R analytics:analytics /app
|
|
USER analytics
|
|
|
|
# Expose port
|
|
EXPOSE 5003
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
|
|
CMD python -c "import requests; requests.get('http://localhost:5003/health').raise_for_status()"
|
|
|
|
# Run the application
|
|
CMD ["python", "app.py"] |