Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
黄南光
/
wiki_knowledge
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 1235aab5
authored
Jun 12, 2026
by
黄南光
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: resolve docker build issues, update docker-compose configs and add frontend Dockerfile
1 parent
baae0610
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
29 deletions
docker-compose.yml
frontend/Dockerfile
docker-compose.yml
View file @
1235aab
version
:
'
3.8'
version
:
'
3.8'
services
:
services
:
db
:
image
:
mysql:8.0
container_name
:
wiki-mysql
restart
:
always
environment
:
# 支持通过 .env 文件配置,如果未提供则使用默认值
MYSQL_ROOT_PASSWORD
:
${MYSQL_ROOT_PASSWORD:-rootpassword}
MYSQL_DATABASE
:
${MYSQL_DATABASE:-wiki_db}
MYSQL_USER
:
${MYSQL_USER:-wiki_user}
MYSQL_PASSWORD
:
${MYSQL_PASSWORD:-wikidbpassword}
ports
:
-
"
3306:3306"
volumes
:
-
mysql_data:/var/lib/mysql
# 增加健康检查,确保 MySQL 完全启动后才让后端连接
healthcheck
:
test
:
[
"
CMD"
,
"
mysqladmin"
,
"
ping"
,
"
-h"
,
"
localhost"
]
timeout
:
20s
retries
:
10
backend
:
backend
:
build
:
build
:
context
:
.
context
:
.
dockerfile
:
Dockerfile
dockerfile
:
Dockerfile
container_name
:
wiki-backend
container_name
:
wiki-backend
restart
:
always
restart
:
always
# 依赖 db 的健康状态,避免启动时连不上数据库报错
depends_on
:
db
:
condition
:
service_healthy
environment
:
environment
:
# 保持与 DB 环境变量联动
# 保持与 DB 环境变量联动
-
DB_HOST=${DB_HOST:-db}
-
DB_HOST=${DB_HOST:-db}
-
DB_PORT=${DB_PORT:-3306}
-
DB_PORT=${DB_PORT:-3306}
-
DB_USER=${
MYSQL
_USER:-wiki_user}
-
DB_USER=${
DB
_USER:-wiki_user}
-
DB_PASSWORD=${
MYSQL
_PASSWORD:-wikidbpassword}
-
DB_PASSWORD=${
DB
_PASSWORD:-wikidbpassword}
-
DB_NAME=${
MYSQL_DATABAS
E:-wiki_db}
-
DB_NAME=${
DB_NAM
E:-wiki_db}
# 需要时在服务器系统环境变量或者 .env 里配置大模型 API Key
# 需要时在服务器系统环境变量或者 .env 里配置大模型 API Key
-
DASHSCOPE_API_KEY=${DASHSCOPE_API_KEY}
-
DASHSCOPE_API_KEY=${DASHSCOPE_API_KEY}
ports
:
ports
:
...
@@ -50,6 +26,8 @@ services:
...
@@ -50,6 +26,8 @@ services:
build
:
build
:
context
:
./frontend
context
:
./frontend
dockerfile
:
Dockerfile
dockerfile
:
Dockerfile
args
:
-
NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-http://localhost:8104}
container_name
:
wiki-frontend
container_name
:
wiki-frontend
restart
:
always
restart
:
always
depends_on
:
depends_on
:
...
@@ -59,5 +37,4 @@ services:
...
@@ -59,5 +37,4 @@ services:
ports
:
ports
:
-
"
3000:3000"
-
"
3000:3000"
volumes
:
mysql_data
:
frontend/Dockerfile
0 → 100644
View file @
1235aab
# 使用轻量级 Node.js 镜像
FROM
node:18-alpine
WORKDIR
/app
# 设置 npm 镜像源以加速国内下载
RUN
npm config
set
registry https://registry.npmmirror.com
# 仅拷贝依赖配置文件
COPY package*.json ./
# 安装依赖
RUN
npm install
# 拷贝源文件
COPY . .
# 环境变量:允许在构建时传入 API URL
ARG NEXT_PUBLIC_API_URL
ENV
NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
# 构建项目
RUN
npm run build
# 暴露端口
EXPOSE
3000
# 启动服务
CMD
["npm", "start"]
Write
Preview
Markdown
is supported
Attach a file
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 post a comment