Commit
This commit is contained in:
@@ -1,30 +1,23 @@
|
||||
FROM node:18-slim AS combined-build
|
||||
# Build frontend
|
||||
FROM node:18-slim AS frontend-build
|
||||
WORKDIR /app
|
||||
|
||||
# Copy and install frontend dependencies
|
||||
COPY frontend/package*.json ./frontend/
|
||||
WORKDIR /app/frontend
|
||||
RUN npm install
|
||||
COPY frontend/ .
|
||||
RUN npm run build
|
||||
RUN npm --prefix frontend install
|
||||
COPY frontend/ ./frontend/
|
||||
RUN npm --prefix frontend run build
|
||||
|
||||
# Copy frontend build output to /app directory
|
||||
WORKDIR /app
|
||||
RUN mkdir -p /app/public
|
||||
COPY /app/dist /app/public
|
||||
|
||||
# Setup backend
|
||||
# Build backend
|
||||
FROM node:18-slim AS backend-build
|
||||
WORKDIR /backend
|
||||
COPY backend/package*.json ./
|
||||
RUN npm install
|
||||
COPY backend/ .
|
||||
|
||||
# Setup Nginx to serve the React App
|
||||
# Production image
|
||||
FROM nginx:alpine
|
||||
COPY --from=combined-build /app/public /usr/share/nginx/html
|
||||
|
||||
# Expose ports for frontend and backend
|
||||
EXPOSE 80
|
||||
EXPOSE 3001
|
||||
|
||||
# Run backend and frontend servers
|
||||
CMD ["sh", "-c", "node /app/src/components/server.js & nginx -g 'daemon off;'"]
|
||||
# Copy frontend static files to nginx folder
|
||||
COPY --from=frontend-build /app/frontend/dist /usr/share/nginx/html
|
||||
# Copy backend application
|
||||
COPY --from=backend-build /backend /backend
|
||||
# Start backend and frontend servers
|
||||
CMD ["sh", "-c", "node /backend/server.js & nginx -g 'daemon off;'"]
|
||||
Reference in New Issue
Block a user