FROM node:20-alpine

WORKDIR /app

# Install bash for better shell capabilities
RUN apk add --no-cache bash

# Copy root package.json and install dependencies
COPY package.json package-lock.json ./
RUN npm ci
RUN find ./node_modules -name "next" -print || true # Debugging line

# Copy apps/website and packages for development
COPY apps/website apps/website/
COPY packages core/
COPY apps/website/tsconfig.json apps/website/
COPY scripts scripts/
COPY tsconfig.base.json ./

EXPOSE 3000

# Run from the correct workspace context
CMD ["npm", "run", "dev", "--workspace=@gridpilot/website"]