# syntax=docker/dockerfile:1

FROM node:22-alpine AS frontend

WORKDIR /frontend
COPY web/frontend/package*.json ./
RUN npm ci

COPY web/frontend/ ./
RUN npm run build


FROM python:3.11.3-slim AS runtime

WORKDIR /app
ENV PYTHONUNBUFFERED=1

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

COPY api ./api
COPY conn ./conn
COPY web/__init__.py ./web/__init__.py
COPY web/api ./web/api
COPY --from=frontend /frontend/dist/ticket-web/browser ./web/static

ENV TICKET_WEB_STATIC_DIR=/app/web/static
EXPOSE 8080

CMD ["uvicorn", "web.api.app:app", "--host", "0.0.0.0", "--port", "8080"]
