FROM node:22-alpine

WORKDIR /app

# Install deps (incl. the Better Auth CLI, used by the migration initContainer).
COPY package.json package-lock.json ./
RUN npm ci

COPY tsconfig.json ./
COPY src ./src
RUN npm run build

ENV NODE_ENV=production
EXPOSE 8080
USER node
CMD ["node", "dist/server.js"]
