This commit is contained in:
xiongxiao
2026-01-12 12:25:04 +08:00
parent 183a3b90c1
commit 2962932868
2 changed files with 5 additions and 23 deletions

View File

@@ -68,8 +68,10 @@ main:
- vscode
- docker
stages:
- name: 安装包
script: cd blogs && pnpm i
- name: 打包应用
script: npm run build
script: cd blogs && pnpm build
# 同名镜像构建&推送
- name: Docker build
script: docker build -t ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE}:latest .

View File

@@ -1,31 +1,11 @@
# 多阶段构建:先构建 Hexo 博客
FROM node:18-alpine AS builder
WORKDIR /app
# 复制 package.json 和 pnpm-lock.yaml
COPY blog/package.json blog/pnpm-lock.yaml ./
# 安装 pnpm
RUN npm install -g pnpm
# 安装依赖
RUN pnpm install
# 复制 Hexo 源码
COPY blog/ ./
# 构建静态文件
RUN pnpm run build
# 使用官方 Nginx 镜像作为基础
FROM nginx:alpine
# 删除默认的 Nginx 配置
RUN rm -rf /usr/share/nginx/html/*
# 构建阶段复制静态文件到 Nginx 目录
COPY --from=builder /app/public /usr/share/nginx/html
# 构建好的静态文件复制到 Nginx 目录
COPY blog/public /usr/share/nginx/html
# 暴露 80 端口
EXPOSE 80