FROM python:3.12-slim

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1

WORKDIR /app
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --disable-pip-version-check --upgrade pip \
    && pip install --no-cache-dir --disable-pip-version-check -r /app/requirements.txt \
    && groupadd --gid 1000 tradebot \
    && useradd --uid 1000 --gid tradebot --home-dir /app --shell /usr/sbin/nologin tradebot

COPY --chown=1000:1000 crypto_spot_bot /app/crypto_spot_bot
COPY --chown=1000:1000 README.md /app/README.md
RUN mkdir -p /app/runtime && chown -R 1000:1000 /app/runtime

EXPOSE 8787
USER 1000:1000
STOPSIGNAL SIGTERM
CMD ["python", "-m", "crypto_spot_bot.main"]
