chore: add docker deployment files and scripts

This commit is contained in:
Ding Shuo
2026-03-15 12:19:47 +08:00
parent 43f7cca0c2
commit ccfba711e7
3 changed files with 98 additions and 0 deletions

24
Dockerfile Normal file
View File

@@ -0,0 +1,24 @@
# Stage 1: Build
FROM node:20-slim AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# Stage 2: Serve with Nginx
FROM nginx:alpine
# Copy build output to nginx folder
COPY --from=build /app/dist /usr/share/nginx/html
# Custom nginx config to handle SPA routing if needed
RUN echo 'server { \
listen 80; \
location / { \
root /usr/share/nginx/html; \
index index.html; \
try_files $uri $uri/ /index.html; \
} \
}' > /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]