Spaces:
Sleeping
Sleeping
| # React Frontend Dockerfile (Production Build) | |
| FROM node:18-slim as build | |
| WORKDIR /app | |
| # Copy dependencies | |
| COPY frontend/package*.json ./ | |
| RUN npm install | |
| # Copy source and build | |
| COPY frontend/ . | |
| RUN npm run build | |
| # Serve with Nginx | |
| FROM nginx:alpine | |
| COPY --from=build /app/build /usr/share/nginx/html | |
| # Custom nginx config to proxy /api requests to the node_backend | |
| RUN echo 'server { \ | |
| listen 80; \ | |
| location / { \ | |
| root /usr/share/nginx/html; \ | |
| index index.html; \ | |
| try_files $uri /index.html; \ | |
| } \ | |
| location /api/ { \ | |
| proxy_pass http://node_backend:5003/; \ | |
| proxy_set_header Host $host; \ | |
| proxy_set_header X-Real-IP $remote_addr; \ | |
| } \ | |
| }' > /etc/nginx/conf.d/default.conf | |
| EXPOSE 80 | |
| CMD ["nginx", "-g", "daemon off;"] | |