-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdockerfile
38 lines (26 loc) · 794 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
# Build stage
FROM node:18-alpine AS build
WORKDIR /app
# Copy package.json and package-lock.json first to leverage Docker cache
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy remaining files
COPY . .
# Build the project
RUN npm run build
# Verify that the dist directory exists and contains files
RUN ls -la /app/dist
# Production stage
FROM nginx:alpine
# Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*
# Copy the build output to the Nginx HTML directory
COPY --from=build /app/dist /usr/share/nginx/html
# Expose the default Nginx port
EXPOSE 80
# Add a health check (optional)
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost/ || exit 1
# Start Nginx
CMD ["nginx", "-g", "daemon off;"]