添加dockerfile

This commit is contained in:
2026-07-23 15:54:39 +08:00
parent 63b4959b6b
commit 5fb131ff90
4 changed files with 56 additions and 0 deletions

10
.dockerignore Normal file
View File

@@ -0,0 +1,10 @@
.git
.gitignore
node_modules
dist
*.log
.env
.env.*
!.env.example
.vscode
.idea

3
.gitignore vendored
View File

@@ -11,6 +11,9 @@ node_modules
dist
dist-ssr
*.local
.env
.env.*
!.env.example
# Editor directories and files
.vscode/*

23
Dockerfile Normal file
View File

@@ -0,0 +1,23 @@
FROM node:24-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:24-alpine AS runtime
RUN apk add --no-cache nginx
COPY --from=build /app/dist /usr/share/nginx/html
COPY --from=build /app/server /app/server
COPY docker/nginx.conf /etc/nginx/http.d/default.conf
ENV INQUIRY_API_PORT=5174
EXPOSE 80
CMD ["sh", "-c", "node /app/server/cms-server.mjs & exec nginx -g 'daemon off;'"]

20
docker/nginx.conf Normal file
View File

@@ -0,0 +1,20 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location /api/ {
proxy_pass http://127.0.0.1:5174;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location / {
try_files $uri $uri/ /index.html;
}
}