FROM node:22.16.0-alpine AS builder

WORKDIR /app

RUN apk add --no-cache openjdk21-jre

RUN npm install -g pnpm@10.13.1

RUN mkdir -p ../api

COPY api/legalconsenthub.yml ../api/

COPY legalconsenthub/package.json legalconsenthub/pnpm-lock.yaml ./

RUN pnpm install --frozen-lockfile

COPY legalconsenthub/ .

RUN pnpm build

FROM node:22.16.0-alpine AS runner

WORKDIR /app

RUN npm install -g pnpm@10.13.1

COPY --from=builder /app/.output /app/.output
COPY --from=builder /app/package.json /app/package.json

ENV NODE_ENV=production
ENV HOST=0.0.0.0
ENV PORT=3000

EXPOSE 3000

CMD ["node", ".output/server/index.mjs"]

