FROM node:20-alpine AS frontend
WORKDIR /app
COPY package.json package.json
COPY vite.config.ts tsconfig.json tailwind.config.js postcss.config.cjs index.html ./
COPY frontend ./frontend
RUN npm install && npm run build:frontend

FROM python:3.12-slim
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
ARG VCS_REF
ARG VCS_URL
LABEL org.opencontainers.image.title="Jellomator" \
      org.opencontainers.image.description="A clean dashboard for Arr* suite links and custom service links" \
      org.opencontainers.image.source="${VCS_URL}" \
      org.opencontainers.image.revision="${VCS_REF}"
COPY backend ./backend
COPY public ./public
COPY --from=frontend /app/frontend/dist ./frontend/dist
RUN pip install --no-cache-dir -r backend/requirements.txt
EXPOSE 6363
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "6363"]
