FROM node:20-alpine

# Install Docker CLI (needed to manage instance containers), rsync (provisioning), openssl (cert generation)
RUN apk add --no-cache docker-cli docker-cli-compose rsync openssl

WORKDIR /app

# Install dependencies
COPY api/package.json api/package-lock.json ./
RUN npm ci

# Copy source
COPY api/ .

# Generate Prisma client
RUN npx prisma generate

EXPOSE 5000

CMD ["npx", "tsx", "src/server.ts"]
