FROM node:20-alpine

# Create app directory
WORKDIR /app

# Copy shared module first (as a sibling to server)
COPY shared ./shared

# Setup Server directory
WORKDIR /app/server

# Install dependencies
COPY server/package*.json ./
RUN npm install

# Copy server source code
COPY server/src ./src
COPY server/tsconfig.json ./

# Expose port
EXPOSE 4000

# Run with nodemon watching both src and shared
CMD ["npx", "nodemon", "--watch", "src", "--watch", "../shared", "--exec", "npx ts-node", "src/index.ts"]
