FROM node:20-alpine

WORKDIR /app

# Install production dependencies first so this layer caches well.
COPY package.json package-lock.json* ./
RUN npm ci --omit=dev

# Copy source. Runtime is `tsx`, which transpiles TS on import — no separate build step.
# This is intentional: extensionless schema sibling imports (driven by drizzle-kit's loader)
# can't be resolved by `node` under ESM after tsc compile, so we keep the TS source authoritative.
COPY src ./src
COPY tsconfig.json ./

ENV NODE_ENV=production
EXPOSE 4000
CMD ["npx", "tsx", "src/server.ts"]
