Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CFFP-HB
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chao Sun
CFFP-HB
Commits
c972c432
Commit
c972c432
authored
Jul 24, 2025
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
f0cc97e8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
Dockerfile
+10
-12
No files found.
Dockerfile
View file @
c972c432
# 第一阶段:
使用 HBuilderX CLI 构建
# 第一阶段:
构建项目
FROM
node:16-alpine AS builder
# 设置工作目录
...
...
@@ -7,34 +7,32 @@ WORKDIR /app
# 替换国内镜像源
RUN
sed
-i
's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g'
/etc/apk/repositories
#
复制 Jenkins 中的 HBuilderX 到容器(假设 HBuilderX 在 /var/jenkins_home/HBuilderX
)
COPY
/var/jenkins_home
/HBuilderX /opt/HBuilderX
#
从构建上下文的软链接复制 HBuilderX 到容器(关键修改
)
COPY
.
/HBuilderX /opt/HBuilderX
# 赋予执行权限
RUN
chmod
-R
755 /opt/HBuilderX
# 复制
项目
依赖文件
# 复制依赖文件
COPY
package.json package-lock.json ./
# 安装项目依赖(仅生产依赖,避免开发依赖冲突)
# 安装依赖
RUN
npm config
set
registry https://registry.npmmirror.com
\
&&
npm install
--production
# 复制
项目
源代码
# 复制源代码
COPY
. .
#
使用 HBuilderX CLI 打包 H5(输出到 /app/dist
)
#
执行打包(使用容器内的 HBuilderX
)
RUN
npm run build:h5
\
&&
echo
"构建产物目录结构:"
\
&&
ls
-R
/app/dist
# 生产阶段
:部署到 Nginx
# 生产阶段
(不变)
FROM
docker.m.daocloud.io/library/nginx:alpine
# 复制打包产物
COPY
--from=builder /app/dist /usr/share/nginx/html
# 复制 Nginx 配置
COPY
nginx.conf /etc/nginx/conf.d/default.conf
# 时区和权限配置
# 时区和权限配置
(不变)
RUN
echo
"https://mirrors.aliyun.com/alpine/v3.22/main/"
>
/etc/apk/repositories
&&
\
echo
"https://mirrors.aliyun.com/alpine/v3.22/community/"
>>
/etc/apk/repositories
&&
\
apk update
&&
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment