# Use an official Node.js runtime as a parent image FROM node:18 # Set the working directory inside the container WORKDIR /app # Install xsel for clipboard access (useful for some applications) RUN apt-get update && apt-get install -y xsel # Copy only package.json and package-lock.json (or yarn.lock) initially # This takes advantage of cached Docker layers COPY package*.json ./ # Install dependencies # npm ci is used instead of npm install when you want a clean, exact installation #RUN npm ci --verbose # Try to install dependencies with a retry mechanism #RUN for i in 1 2 3; do npm ci --verbose && break || sleep 15; done # Copy the rest of your application code COPY . . # Set necessary environment variables (if they are not secrets) ENV NODE_ENV=development ENV VITE_API_URL_LOCAL=https://localhost:5001 ENV VITE_API_URL_SERVER=https://localhost # Expose port 3000 for the application EXPOSE 3000 # Install global dependencies if absolutely necessary (generally not recommended to do globally) RUN npm install -g serve vite # Build the application RUN node --max-old-space-size=4096 node_modules/.bin/vite build # Command to run the application CMD ["npm", "run", "serve"]