FROM python:3.11-slim

WORKDIR /app

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1

# Install build dependencies for numpy/pandas and git for pip installs from GitHub
RUN apt-get update && apt-get install -y --no-install-recommends \
    gcc \
    g++ \
    git \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

ARG CACHE_BUST=20260710_true_digital
RUN echo "Docker cache bust: ${CACHE_BUST}"
COPY requirements.txt .
RUN python -m pip install --upgrade pip setuptools wheel \
    && pip install --no-cache-dir -r requirements.txt \
    && python -c "import websocket, requests, pandas, numpy; print('direct websocket deps OK')"

COPY iq_signal_worker.py .
RUN ! grep -R "iqoptionapi\|stable_api\|IQ_Option" /app/iq_signal_worker.py \
    && python -m py_compile /app/iq_signal_worker.py \
    && head -n 45 /app/iq_signal_worker.py

# Railway healthcheck: worker must be connected to IQ Option
CMD ["python", "-B", "-u", "/app/iq_signal_worker.py"]
