FROM node:20-alpine

RUN corepack enable && corepack prepare pnpm@latest --activate

WORKDIR /app

COPY package.json pnpm-lock.yaml ./
RUN pnpm install

COPY server.ts ./
COPY src/api ./src/api
COPY src/lib ./src/lib
COPY src/declarations.d.ts ./src/
COPY tsconfig.json tsconfig.server.json ./

RUN pnpm tsc -p tsconfig.server.json

EXPOSE 3000

CMD ["node", "dist/server.js"]
