29 lines
652 B
Docker
29 lines
652 B
Docker
# Stage 1: Build the React app (Frontend)
|
|
FROM node:18-slim AS frontend-build
|
|
WORKDIR /app
|
|
|
|
# Copy frontend files
|
|
COPY frontend/package*.json ./frontend/
|
|
WORKDIR /app/frontend
|
|
RUN npm install
|
|
COPY frontend/ .
|
|
RUN npm run build
|
|
|
|
# Stage 2: Setup Nginx to serve the React App
|
|
FROM nginx:alpine AS frontend-server
|
|
COPY --from=frontend-build /app/frontend/dist /usr/share/nginx/html
|
|
EXPOSE 80
|
|
CMD ["nginx", "-g", "daemon off;"]
|
|
|
|
# Stage 3: Setup the Backend
|
|
FROM node:18-slim AS backend
|
|
WORKDIR /app
|
|
|
|
# Copy backend files
|
|
COPY backend/package*.json ./
|
|
RUN npm install
|
|
COPY backend/ .
|
|
|
|
# Run backend
|
|
EXPOSE 3001
|
|
CMD ["node", "/app/src/components/server.js"] |