| # Use Node.js 18 as base image | |
| FROM node:18-alpine | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy package files for both frontend and backend | |
| COPY crossword-app/frontend/package*.json ./frontend/ | |
| COPY crossword-app/backend/package*.json ./backend/ | |
| # Install dependencies for both frontend and backend | |
| RUN cd frontend && npm ci | |
| RUN cd backend && npm ci --only=production | |
| # Copy source code | |
| COPY crossword-app/frontend/ ./frontend/ | |
| COPY crossword-app/backend/ ./backend/ | |
| # Build the React frontend | |
| RUN cd frontend && npm run build | |
| # Copy built frontend files to backend public directory | |
| RUN mkdir -p backend/public && cp -r frontend/dist/* backend/public/ | |
| # Set working directory to backend for runtime | |
| WORKDIR /app/backend | |
| # Expose port 7860 (Hugging Face Spaces standard) | |
| EXPOSE 7860 | |
| # Set environment to production | |
| ENV NODE_ENV=production | |
| ENV PORT=7860 | |
| # Start the backend server | |
| CMD ["npm", "start"] |