File size: 705 Bytes
7f2a14a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Use the official Node.js image
FROM node:20

# Create and change to the app directory
WORKDIR /usr/src/app

# Copy application dependency manifests to the container image
COPY package*.json ./

# Install production dependencies
RUN npm install

# Copy application code and environment variables
COPY . .

# Build the React app
RUN npm run build

# Install serve to properly serve the static files
RUN npm install -g serve

# Expose the ports the app runs on
EXPOSE 3000
EXPOSE 3001

# Create a script to run both services
RUN echo '#!/bin/bash\n\
npm run start-server & \
serve -s build -l 3000\n\
wait' > start-services.sh && chmod +x start-services.sh

# Run both services
CMD ["./start-services.sh"]