i-darrshan's picture
initial push of the update
8b105ad
raw
history blame
921 Bytes
# Stage 1: Build the React frontend
FROM node:16 AS build
# Set the working directory
WORKDIR /app
# Copy the React frontend code
COPY frontend/package.json frontend/package-lock.json ./frontend/
RUN cd frontend && npm install
# Build the React app (inside the frontend folder)
COPY frontend ./frontend
RUN cd frontend && npm run build
# Stage 2: Set up the Node.js backend
FROM node:16
# Set the working directory
WORKDIR /app
# Copy backend code
COPY backend/package.json backend/package-lock.json ./backend/
RUN cd backend && npm install
# Copy the React build files from Stage 1 to the backend/build folder
COPY --from=build /app/frontend/build ./backend/build
# Copy the backend source code
COPY backend ./backend
RUN mkdir -p /app/backend/database && chmod -R 777 /app/backend/database
# Expose the backend's port
EXPOSE 7860
WORKDIR /app/backend
# Start the backend server
CMD [ "node", "./index.js"]