File size: 921 Bytes
e08ecbf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
37
38
39
40
41
# 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"]