-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathDockerfile.prod
More file actions
44 lines (34 loc) · 976 Bytes
/
Dockerfile.prod
File metadata and controls
44 lines (34 loc) · 976 Bytes
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
# Stage 1: Build the frontend
FROM node:20-alpine AS build
# Set the working directory
WORKDIR /app
# Copy package.json
COPY package.json .
# Install production dependencies using Yarn
RUN npm install --production
# Copy the rest of the application files
COPY . .
# Build the frontend using Yarn
RUN npm run build
# Stage 2: Serve the application with Nginx
FROM nginx:alpine
# Copy the build output from the previous stage to Nginx's serve directory
COPY --from=build /app/dist /usr/share/nginx/html
# Remove the default Nginx configuration file
RUN rm /etc/nginx/conf.d/default.conf
# Create a new Nginx configuration file
RUN echo $'\
server { \n\
listen 3000; \n\
server_name localhost; \n\
root /usr/share/nginx/html; \n\
index index.html; \n\
\n\
location / { \n\
try_files $uri $uri/ /index.html; \n\
} \n\
}' > /etc/nginx/conf.d/default.conf
# Expose port 3000
EXPOSE 3000
# Start Nginx
CMD ["nginx", "-g", "daemon off;"]