-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
51 lines (35 loc) · 922 Bytes
/
Dockerfile
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
42
43
44
45
46
47
48
49
50
51
# Use the official Node.js image as the base image
FROM node:16 as build
# Set working directory
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code
COPY . .
# Copy .env file if it exists
COPY .env .env
# Build the React app
RUN npm run build
# Use the official Node.js image for the backend
FROM node:16
# Set working directory
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code
COPY . .
# Copy built React app from the build stage
COPY --from=build /app/build /app/build
# Copy .env file if it exists
COPY .env .env
# Set environment variables
ENV NODE_ENV=production
ENV PORT=5000
# Expose the port the app runs on
EXPOSE 5000
# Command to run the application
CMD ["npm", "run", "server:prod"]