13 / Dockerfile
Samuraiog's picture
Update Dockerfile
3f0c05b verified
raw
history blame
1.51 kB
# Multi-stage Docker build for Phoenix Fury API v7.0
FROM python:3.11-slim as builder
# Set environment variables for Python optimization
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
make \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements and install Python dependencies
COPY requirements.txt /tmp/
RUN pip install --user -r /tmp/requirements.txt
# Final stage
FROM python:3.11-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PATH=/root/.local/bin:$PATH
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libcap2-bin \
&& rm -rf /var/lib/apt/lists/*
# Copy Python dependencies from builder
COPY --from=builder /root/.local /root/.local
# Create app directory
WORKDIR /app
# Copy application code
COPY main.py /app/
# Grant raw socket capabilities (for L4 attacks without full root)
# Note: Container must still run with --cap-add=NET_RAW or privileged mode
RUN setcap cap_net_raw+ep /usr/local/bin/python3.11 || true
# Expose API port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python3 -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/').read()" || exit 1
# Run the application
CMD ["python3", "main.py"]