30 lines
700 B
Docker
30 lines
700 B
Docker
FROM node:18-slim AS combined-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
|
|
|
|
# Copy frontend build output to /app directory
|
|
WORKDIR /app
|
|
RUN mkdir -p /app/public
|
|
COPY /app/frontend/dist /app/public
|
|
|
|
# Setup backend
|
|
COPY backend/package*.json ./
|
|
RUN npm install
|
|
COPY backend/ .
|
|
|
|
# Setup Nginx to serve the React App
|
|
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;'"] |