FROM node:22-alpine

WORKDIR /app

COPY package.json package-lock.json* ./
RUN npm install --network-timeout=600000 --retry 3

COPY . .

# Startup script that ensures node_modules are in sync with package.json
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh

EXPOSE 5173

ENTRYPOINT ["/docker-entrypoint.sh"]
