49 lines
1.1 KiB
Docker
49 lines
1.1 KiB
Docker
# Multi-stage build for optimized image size
|
|
FROM python:3.11-slim as builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install build dependencies
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
gcc \
|
|
git \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy requirements and install Python packages
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
# Final stage
|
|
FROM python:3.11-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy Python packages from builder
|
|
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
|
|
COPY --from=builder /usr/local/bin /usr/local/bin
|
|
|
|
# Copy application code
|
|
COPY config ./config
|
|
COPY analysis ./analysis
|
|
COPY signals ./signals
|
|
COPY notifiers ./notifiers
|
|
COPY scheduler.py .
|
|
COPY .env.example .env
|
|
|
|
# Create output directory
|
|
RUN mkdir -p /app/output
|
|
|
|
# Create non-root user for security
|
|
RUN useradd -m -u 1000 appuser && \
|
|
chown -R appuser:appuser /app
|
|
|
|
USER appuser
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
|
CMD python -c "import sys; sys.exit(0)"
|
|
|
|
# Run scheduler by default
|
|
CMD ["python", "-u", "scheduler.py"]
|