# Client build
FROM node:22.13 AS client-builder

WORKDIR /app/client

# kind of retarded but such is a price for inlining dependencies
COPY client/fluid-player/package.json client/fluid-player/package-lock.json ./fluid-player/

COPY client/package.json client/package-lock.json ./

RUN npm ci --include=dev

COPY schema ../schema

COPY config.json ../config.json

COPY client ./

RUN npm run build

# Server build
FROM python:3.12 AS server-builder

RUN apt-get update \
  && apt-get install -y libpq-dev

WORKDIR /app

COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt

COPY . /app

COPY --from=client-builder /app/client/dist ./client/dist

ENV LANG=C.UTF-8
ARG GIT_COMMIT_HASH
ENV GIT_COMMIT_HASH=${GIT_COMMIT_HASH:-undefined}
ARG BUILD_DATE
ENV BUILD_DATE=${BUILD_DATE:-undefined}

CMD python -m src daemon
