Docker 构建加固:npm ci + 依赖自检;新增预构建 Dockerfile 与 dist 产物
This commit is contained in:
@@ -1,2 +1 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
dist/
|
|
||||||
|
|||||||
+4
-1
@@ -10,7 +10,10 @@ COPY package.json package-lock.json* ./
|
|||||||
|
|
||||||
# 国内网络环境可取消下一行注释使用镜像源
|
# 国内网络环境可取消下一行注释使用镜像源
|
||||||
# RUN npm config set registry https://registry.npmmirror.com
|
# RUN npm config set registry https://registry.npmmirror.com
|
||||||
RUN npm install --include=dev
|
RUN npm ci --include=dev
|
||||||
|
|
||||||
|
# 依赖自检:如果 tsc/vite 没装上,在这里就明确失败而不是 127
|
||||||
|
RUN ./node_modules/.bin/tsc --version && ./node_modules/.bin/vite --version
|
||||||
|
|
||||||
# 拷贝源码并构建(产物输出到 /app/dist)
|
# 拷贝源码并构建(产物输出到 /app/dist)
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# 预构建部署:不跑 npm,直接把仓库里已构建好的 dist/ 交给 Nginx
|
||||||
|
# 适合 npm 安装受限的网络环境。用法:
|
||||||
|
# docker build -f Dockerfile.prebuilt -t buzhou .
|
||||||
|
FROM nginx:1.27-alpine
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
COPY dist /usr/share/nginx/html
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+4280
File diff suppressed because one or more lines are too long
Vendored
+19
@@ -0,0 +1,19 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>不周 · 月球观测日志</title>
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||||
|
<link
|
||||||
|
href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@300;600&family=JetBrains+Mono:wght@400&display=swap"
|
||||||
|
rel="stylesheet"
|
||||||
|
/>
|
||||||
|
<script type="module" crossorigin src="./assets/index-D34tEj7q.js"></script>
|
||||||
|
<link rel="stylesheet" crossorigin href="./assets/index-CLQdFjpd.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user