Spaces:
Sleeping
Sleeping
File size: 791 Bytes
0f95125 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | # 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;"]
|