2024-04-14 15:20:14 +08:00
|
|
|
# Stage 1: Build the app
|
2024-04-07 23:26:48 +08:00
|
|
|
FROM node:20-alpine as build
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package*.json ./
|
|
|
|
RUN npm ci
|
|
|
|
COPY . .
|
|
|
|
RUN npm run build
|
|
|
|
|
2024-04-14 15:20:14 +08:00
|
|
|
# Stage 2: Setup the Nginx Server to serve the app
|
2024-04-07 23:26:48 +08:00
|
|
|
FROM nginx:stable-alpine3.17 as production
|
|
|
|
COPY --from=build /app/dist /usr/share/nginx/html
|
2024-04-10 13:51:04 +08:00
|
|
|
RUN echo 'server { listen 80; server_name _; root /usr/share/nginx/html; location / { try_files $uri /index.html; } }' > /etc/nginx/conf.d/default.conf
|
2024-04-07 23:26:48 +08:00
|
|
|
EXPOSE 80
|
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|