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
2bc31c5f
Commit
2bc31c5f
authored
Aug 04, 2025
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
d4134b1d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
23 deletions
+109
-23
Dockerfile
+94
-0
jenkins/Dockerfile
+0
-17
nginx.conf
+15
-6
No files found.
Dockerfile
0 → 100644
View file @
2bc31c5f
# Dockerfile (位于项目根目录)
# 第一阶段:构建环境
FROM
ubuntu:20.04 AS builder
# 设置时区
ENV
TZ=Asia/Shanghai
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
# 安装 HBuilderX
ARG
HBUILDER_VERSION=3.8.12
RUN
wget
-O
HBuilderX.tar.gz https://download1.dcloud.net.cn/download/HBuilderX.
${
HBUILDER_VERSION
}
.linux-x64.tar.gz
&&
\
tar
-xzf
HBuilderX.tar.gz
-C
/opt
&&
\
rm HBuilderX.tar.gz
&&
\
chmod 755 /opt/HBuilderX/cli
&&
\
chmod 755 /opt/HBuilderX/HBuilderX
# 设置工作目录
WORKDIR
/app
# 复制项目文件
#COPY jenkins .
# 配置 npm 镜像源
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 (注意:实际使用时请使用更安全的方式管理凭证)
RUN
/opt/HBuilderX/cli user login
--username
15026705202
--password
Wo7320017
# 构建项目
RUN
/opt/HBuilderX/cli publish
--platform
h5
--project
.
--output
dist
# 第二阶段:运行环境
FROM
nginx:1.25-alpine
# 删除默认配置
RUN
rm /etc/nginx/conf.d/default.conf
# 复制自定义 Nginx 配置
COPY
nginx.conf /etc/nginx/conf.d/app.conf
# 从构建阶段复制构建产物
COPY
--from=builder /app/dist /usr/share/nginx/html
# 暴露端口
EXPOSE
8333
# 启动 Nginx
CMD
["nginx", "-g", "daemon off;"]
jenkins/Dockerfile
deleted
100644 → 0
View file @
d4134b1d
# 使用官方Nginx镜像
FROM
nginx:alpine
# 删除默认配置
RUN
rm /etc/nginx/conf.d/default.conf
# 复制自定义Nginx配置
COPY
jenkins/nginx.conf /etc/nginx/conf.d/app.conf
# 复制H5构建产物
COPY
dist /usr/share/nginx/html
# 暴露端口
EXPOSE
8333
# 启动Nginx(非后台模式)
CMD
["nginx", "-g", "daemon off;"]
jenkins/
nginx.conf
→
nginx.conf
View file @
2bc31c5f
# nginx.conf
server
{
listen
8333
;
server_name
localhost
;
location
/
{
root
/usr/share/nginx/html
;
index
index.html
;
try_files
$uri
$uri
/
/index.html
;
# 支持Vue路由History模式
location
/
{
try_files
$uri
$uri
/
/index.html
;
add_header
Cache-Control
"no-cache,
no-store,
must-revalidate"
;
add_header
Pragma
"no-cache"
;
add_header
Expires
0
;
}
# 可选:API代理
location
/api
{
proxy_pass
http://backend-service
;
proxy_set_header
Host
$host
;
location
~
*
\
.(js|css|png|jpg|jpeg|gif|ico|svg)
$
{
expires
1y
;
add_header
Cache-Control
"public"
;
}
error_page
500
502
503
504
/50x.html
;
location
=
/50x.html
{
root
/usr/share/nginx/html
;
}
}
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