添加了 docker 发布
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
# 1. 第一阶段:构建
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
|
||||
COPY . .
|
||||
|
||||
# 2. 根据 MODE 参数执行对应的打包命令
|
||||
RUN npm run build
|
||||
|
||||
# 2. 第二阶段:部署
|
||||
FROM nginx:stable-alpine
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
try_files $uri $uri/ /index.html;
|
||||
|
||||
# 针对 HTML 文件设置不缓存
|
||||
if ($request_filename ~* .*\.(?:htm|html)$ ) {
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
}
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
const webpack = require('webpack');
|
||||
|
||||
module.exports = {
|
||||
publicPath: '/plus-6/',
|
||||
outputDir: "dist",
|
||||
// publicPath: '/plus-6/',
|
||||
// outputDir: "dist",
|
||||
transpileDependencies: true,
|
||||
productionSourceMap: false,
|
||||
devServer: {
|
||||
|
||||
Reference in New Issue
Block a user