| # Use an official Node runtime as a parent image | |
| FROM node:18 | |
| # Install nodemon globally | |
| RUN npm install -g nodemon | |
| # Create a directory for the application | |
| WORKDIR /app | |
| # Copy package.json and package-lock.json for both frontend and backend | |
| COPY frontend/package*.json ./frontend/ | |
| COPY backend/package*.json ./backend/ | |
| # Install dependencies for frontend | |
| WORKDIR /app/frontend | |
| RUN npm install | |
| # Install dependencies for backend | |
| WORKDIR /app/backend | |
| RUN npm install | |
| # Copy the rest of the application code | |
| WORKDIR /app | |
| COPY . . | |
| # Set correct permissions for all files | |
| RUN chmod -R 755 /app/frontend /app/backend /app/backend/engine | |
| # Expose the ports | |
| EXPOSE 5173 | |
| EXPOSE 3000 | |
| # Define the command to run the apps using nodemon | |
| CMD ["sh", "-c", "nodemon --watch /app/frontend --exec 'npm run dev --prefix /app/frontend' & nodemon --watch /app/backend --exec 'npm run dev --prefix /app/backend'"] | |