# The results Portal on a Linux server (Dokploy, 2026-10-27): Sign-in,
# Dashboard, Claim status, Runs. The bot runs only on the Windows PC, so
# PORTAL_SERVER=1 turns Start / Stop off. Set RESULTS_DB_CONN (a SQL login)
# and PORTAL_URLS in Dokploy's environment — never in Git (.env.example).
FROM python:3.13-slim-bookworm

# Microsoft ODBC Driver 18 for SQL Server, for pyodbc. libgssapi-krb5-2 by
# name: the driver needs it, and autoremove took it with curl otherwise.
RUN apt-get update \
 && apt-get install -y --no-install-recommends curl gnupg ca-certificates \
 && curl -fsSL https://packages.microsoft.com/keys/microsoft.asc \
    | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg \
 && curl -fsSL https://packages.microsoft.com/config/debian/12/prod.list \
    -o /etc/apt/sources.list.d/mssql-release.list \
 && apt-get update \
 && ACCEPT_EULA=Y apt-get install -y --no-install-recommends msodbcsql18 libgssapi-krb5-2 tzdata \
 && apt-get purge -y curl gnupg && apt-get autoremove -y \
 && rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY requirements-portal.txt .
RUN pip install --no-cache-dir -r requirements-portal.txt
COPY src ./src
COPY web ./web

RUN useradd --create-home portal
USER portal
# India time, like the bot's rows: Sign-ins and "today" in IST, not UTC.
ENV PORTAL_SERVER=1 PYTHONUNBUFFERED=1 TZ=Asia/Kolkata
EXPOSE 8000
CMD ["python", "-m", "uvicorn", "web.app:app", "--host", "0.0.0.0", \
     "--port", "8000", "--proxy-headers", "--forwarded-allow-ips", "*"]
