FROM python:3.12-slim

ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .
# Vendor Chart.js at build time so the running app needs no CDN
ADD https://cdn.jsdelivr.net/npm/chart.js@4.4.6/dist/chart.umd.min.js /app/static/chart.umd.min.js

RUN useradd -u 1000 -m app && chown -R app /app
USER app

EXPOSE 8000
# Single worker on purpose: the background scheduler (price refresh, bank sync) runs in-process.
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--proxy-headers", "--forwarded-allow-ips", "*"]
