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
321665c7
Commit
321665c7
authored
Aug 04, 2025
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
9cea9ad9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
81 deletions
+12
-81
Dockerfile
+12
-81
No files found.
Dockerfile
View file @
321665c7
# Dockerfile
# 使用 Nginx 基础镜像
# 第一阶段:构建环境
FROM
nginx:1.25-alpine
FROM
ubuntu:20.04 AS builder
# 安装 Node.js 和基本依赖
RUN
apk add
--no-cache
\
nodejs
\
npm
\
curl
\
bash
# 设置时区
# 设置时区
ENV
TZ=Asia/Shanghai
ENV
TZ=Asia/Shanghai
RUN
ln
-snf
/usr/share/zoneinfo/
$TZ
/etc/localtime
&&
echo
$TZ
>
/etc/timezone
RUN
ln
-snf
/usr/share/zoneinfo/
$TZ
/etc/localtime
&&
echo
$TZ
>
/etc/timezone
# 使用阿里云镜像源
RUN
sed
-i
's@archive.ubuntu.com@mirrors.aliyun.com@g'
/etc/apt/sources.list
&&
\
sed
-i
's@security.ubuntu.com@mirrors.aliyun.com@g'
/etc/apt/sources.list
# 安装基础依赖
RUN
apt-get update
&&
apt-get install
-y
--no-install-recommends
\
ca-certificates
\
curl
\
wget
\
gnupg2
\
build-essential
\
libglib2.0-0
\
libnss3
\
libatk1.0-0
\
libcups2
\
libdrm2
\
libxkbcommon0
\
libxcomposite1
\
libxdamage1
\
libxrandr2
\
libgbm1
\
libgtk-3-0
\
libpango-1.0-0
\
libcairo2
\
libasound2
\
libx11-xcb1
\
libxshmfence1
\
libxcb-dri3-0
\
libqt5core5a
\
libqt5gui5
\
libqt5network5
\
libqt5widgets5
\
libqt5svg5
\
libqt5websockets5
\
libicu66
\
&&
rm
-rf
/var/lib/apt/lists/
*
# 安装 Node.js
RUN
curl
-fsSL
https://deb.nodesource.com/setup_20.x | bash -
&&
\
apt-get install
-y
nodejs
# 设置工作目录
# 设置工作目录
WORKDIR
/app
WORKDIR
/app
# 复制项目文件
# 复制项目文件
COPY
. .
COPY
. .
# 配置 npm 镜像源
# 配置 npm 镜像源 (简化版)
RUN
npm config
set
registry https://registry.npmmirror.com
&&
\
RUN
npm config
set
registry https://registry.npmmirror.com
npm config
set
disturl https://npmmirror.com/dist
&&
\
npm config
set
sass_binary_site https://npmmirror.com/mirrors/node-sass/
# 安装项目依赖
RUN
npm install
--no-audit
# 复制 HBuilderX (使用构建上下文中的副本)
COPY
hbuilder_temp_* /opt/HBuilderX
# 修复 HBuilderX 权限
RUN
chmod 755 /opt/HBuilderX/cli
&&
\
chmod 755 /opt/HBuilderX/HBuilderX
&&
\
find /opt/HBuilderX
-name
"lib*.so*"
-exec
chmod 755
{}
\;
# 设置 Qt 库路径
ENV
LD_LIBRARY_PATH=/opt/HBuilderX:$LD_LIBRARY_PATH
# 登录 HBuilderX
ARG
HB_USERNAME
ARG
HB_PASSWORD
RUN
/opt/HBuilderX/cli user login
--username
"
$HB_USERNAME
"
--password
"
$HB_PASSWORD
"
# 构建项目
RUN
/opt/HBuilderX/cli publish
--platform
h5
--project
.
--output
dist
# 第二阶段:运行环境
FROM
nginx:1.25-alpine
# 删除默认配置
RUN
rm /etc/nginx/conf.d/default.conf
# 复制自定义 Nginx 配置
# 复制自定义 Nginx 配置
COPY
nginx.conf /etc/nginx/conf.d/app.conf
COPY
nginx.conf /etc/nginx/conf.d/app.conf
# 从构建阶段复制构建产物
COPY
--from=builder /app/dist /usr/share/nginx/html
# 暴露端口
# 暴露端口
EXPOSE
8333
EXPOSE
8333
# 启动 Nginx
# 注意:这里不设置默认 CMD,将在运行时指定
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