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
f81f011a
Commit
f81f011a
authored
Jul 24, 2025
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
3c2c44f0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
15 deletions
+11
-15
Dockerfile
+11
-15
No files found.
Dockerfile
View file @
f81f011a
#
替换基础镜像为Node.js 16
#
注意:此方案需要在Docker中安装HBuilderX CLI,步骤较特殊
FROM
node:16-alpine AS builder
WORKDIR
/app
# 系统依赖配置
RUN
sed
-i
's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g'
/etc/apk/repositories
\
&&
apk add
--no-cache
python3 make g++
# 安装HBuilderX CLI(关键:使用官方提供的CLI工具,而非npm包)
RUN
apk add
--no-cache
wget unzip
\
&&
wget https://download.dcloud.net.cn/hbuilderx/alpha/HBuilderX.3.99.20231011.full.zip
-O
hbx.zip
\
&&
unzip hbx.zip
-d
/opt/hbuilderx
\
&&
chmod +x /opt/hbuilderx/cli
# 复制修正后的package.json
COPY
package.json ./
# 重新安装依赖(使用官方源+适配Node.js 16)
RUN
npm config
set
registry https://registry.npmjs.org
\
&&
npm cache clean
--force
\
&&
npm install
--legacy-peer-deps
# 复制源代码并构建
# 复制项目文件(假设项目是HBuilderX创建的标准结构)
COPY
. .
RUN
npm run build:h5
# 使用HBuilderX CLI构建H5项目(避开npm依赖)
RUN
/opt/hbuilderx/cli publish
--platform
h5
--project
.
--outDir
dist
# 生产环境
FROM
nginx:1.21-alpine
COPY
--from=builder /app/dist
/build/h5
/usr/share/nginx/html
COPY
--from=builder /app/dist /usr/share/nginx/html
COPY
nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE
8333
CMD
["nginx", "-g", "daemon off;"]
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