# syntax=docker/dockerfile:1

FROM node:20-alpine AS deps
WORKDIR /app

COPY package.json package-lock.json ./
RUN npm ci


FROM node:20-alpine AS build
WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY . .

RUN npm run build


FROM node:20-alpine AS runner
WORKDIR /app

ENV NODE_ENV=production
ENV NITRO_HOST=0.0.0.0
ENV NITRO_PORT=3001
ENV HOST=0.0.0.0
ENV PORT=3001
ENV AUTH_ORIGIN=http://localhost:3001

COPY --from=build /app/.output ./.output

RUN chown -R node:node /app
USER node

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