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
4c317d6e
Commit
4c317d6e
authored
Jul 24, 2025
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
49fd9bd5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
39 deletions
+23
-39
Dockerfile
+3
-4
nginx.conf
+4
-17
vite.config.js
+16
-18
No files found.
Dockerfile
View file @
4c317d6e
...
...
@@ -22,11 +22,11 @@ RUN npm run build
# 生产阶段
FROM
docker.m.daocloud.io/library/nginx:alpine
#
关键修改:直接复制 cffp 目录到 Nginx 根目录
COPY
--from=builder /app/dist
/cffp
/usr/share/nginx/html
#
直接复制 dist 根目录到 Nginx 根目录(匹配容器内实际路径)
COPY
--from=builder /app/dist /usr/share/nginx/html
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
&&
\
...
...
@@ -34,7 +34,6 @@ RUN echo "https://mirrors.aliyun.com/alpine/v3.22/main/" > /etc/apk/repositories
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
&&
\
echo
"Asia/Shanghai"
>
/etc/timezone
# 设置文件权限
RUN
chown
-R
nginx:nginx /usr/share/nginx/html
\
&&
chmod
-R
755 /usr/share/nginx/html
...
...
nginx.conf
View file @
4c317d6e
...
...
@@ -2,18 +2,14 @@ server {
listen
8333
;
server_name
localhost
;
root
/usr/share/nginx/html
;
root
/usr/share/nginx/html
;
# 直接指向资源所在的根目录
index
index.html
;
# 确保正确的 MIME 类型
include
/etc/nginx/mime.types
;
# 静态资源
直接返回,不经过 try_files
location
~
*
\
.(js|css|png|jpg|
jpeg|gif|ico|svg|woff|woff2
|ttf|eot)
$
{
expires
1y
;
# 静态资源缓存
# 静态资源
处理(匹配实际 assets 目录)
location
~
*
\
.(js|css|png|jpg|
svg|woff2?
|ttf|eot)
$
{
expires
1y
;
add_header
Cache-Control
"public"
;
access_log
off
;
log_not_found
off
;
}
# 主应用路由(history 模式)
...
...
@@ -22,11 +18,6 @@ server {
add_header
Cache-Control
"no-store,
no-cache,
must-revalidate"
;
}
# 子应用 /cffp/ 路由(关键修正)
location
/cffp/
{
try_files
$uri
$uri
/
/index.html
;
# 改为指向根目录的 index.html
}
# 禁止访问 .env 文件
location
~
/\.env
{
deny
all
;
...
...
@@ -38,8 +29,4 @@ server {
location
=
/50x.html
{
root
/usr/share/nginx/html
;
}
# 访问日志
access_log
/var/log/nginx/access.log
;
error_log
/var/log/nginx/error.log
;
}
vite.config.js
View file @
4c317d6e
...
...
@@ -16,29 +16,27 @@ export default defineConfig({
}
},
// 开发服务器配置
server
:
{
port
:
8080
,
proxy
:
{
// 代理后端 API 请求
'/cffpApi'
:
{
target
:
'http://localhost:8080'
,
changeOrigin
:
true
,
rewrite
:
(
path
)
=>
path
.
replace
(
/^
\/
cffpApi/
,
''
)
}
}
},
//
//
开发服务器配置
//
server: {
//
port: 8080,
//
proxy: {
//
// 代理后端 API 请求
//
'/cffpApi': {
//
target: 'http://localhost:8080',
//
changeOrigin: true,
//
rewrite: (path) => path.replace(/^\/cffpApi/, '')
//
}
//
}
//
},
// 生产环境构建配置
build
:
{
outDir
:
'dist
/cffp'
,
// 关键修改:输出目录改为 dist/cffp
assetsDir
:
'assets'
,
// 静态资源目录
outDir
:
'dist
'
,
// 输出到 dist 根目录(而非 dist/cffp)
assetsDir
:
'assets'
,
rollupOptions
:
{
output
:
{
// 确保生成的资源路径正确
assetFileNames
:
'assets/[name].[hash].[ext]'
,
entryFileNames
:
'assets/[name].[hash].js'
,
chunkFileNames
:
'assets/[name].[hash].js'
,
entryFileNames
:
'assets/[name].[hash].js
'
assetFileNames
:
'assets/[name].[hash].[ext]
'
}
}
}
...
...
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