FROM oven/bun:1.3.11

WORKDIR /app

ENV NODE_ENV=production
ENV VIRTUAL_ENV=/opt/ingest-options-venv
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"

COPY --from=workspace package.json ./package.json
COPY --from=workspace bun.lock ./bun.lock
COPY --from=workspace tsconfig.base.json ./tsconfig.base.json
COPY --from=services . ./services
COPY --from=packages . ./packages
COPY --from=apps . ./apps

RUN apt-get update \
  && apt-get install -y --no-install-recommends python3 python3-pip python3-venv \
  && rm -rf /var/lib/apt/lists/* \
  && python3 -m venv "${VIRTUAL_ENV}" \
  && "${VIRTUAL_ENV}/bin/pip" install --no-cache-dir -r services/ingest-options/py/requirements.txt \
  && bun install --frozen-lockfile

ENTRYPOINT ["bun"]
