前端打包

This commit is contained in:
2025-11-24 16:53:17 +08:00
parent df57d05817
commit b51faf731a
10 changed files with 218 additions and 385 deletions

View File

@@ -17,15 +17,16 @@ RUN mkdir -p /docker-entrypoint-initdb.d /opt/sql
# 复制所有SQL文件保持目录结构
COPY schoolNewsServ/.bin/mysql/sql/ /opt/sql/
# 复制并调整reInit.sh为Docker环境
# 复制并调整reInit.sh为Docker环境,设置执行权限
COPY schoolNewsServ/.bin/mysql/sql/reInit.sh /opt/sql/
RUN sed -i 's/DB_HOST="localhost"/DB_HOST="localhost"/' /opt/sql/reInit.sh && \
sed -i 's/DB_PORT="3306"/DB_PORT="3306"/' /opt/sql/reInit.sh && \
sed -i 's/DB_USER="root"/DB_USER="root"/' /opt/sql/reInit.sh && \
sed -i 's/DB_PASSWORD="123456"/DB_PASSWORD="${MYSQL_ROOT_PASSWORD}"/' /opt/sql/reInit.sh && \
sed -i 's/DB_NAME="school_news"/DB_NAME="${MYSQL_DATABASE}"/' /opt/sql/reInit.sh && \
chmod +x /opt/sql/reInit.sh
sed -i 's|LOG_FILE="$SCRIPT_DIR/reInit.log"|LOG_FILE="/tmp/reInit.log"|' /opt/sql/reInit.sh && \
chmod +x /opt/sql/reInit.sh && \
chmod +x /opt/sql/sensitiveData/importSensitiveWords.sh
# 创建Docker初始化适配脚本
RUN cat > /docker-entrypoint-initdb.d/01-init-database.sh <<'EOF'
#!/bin/bash
@@ -54,10 +55,8 @@ export DB_PASSWORD="${MYSQL_ROOT_PASSWORD}"
export DB_NAME="${MYSQL_DATABASE}"
export MYSQL_PWD="${MYSQL_ROOT_PASSWORD}"
# 直接调用reInit.sh的初始化函数
echo "执行数据库初始化..."
# Source reInit.sh并调用其初始化函数
echo "执行数据库初始化使用reInit.sh..."
source reInit.sh
# 调用reInit.sh的核心函数跳过备份和删除
@@ -76,11 +75,9 @@ UPDATE tb_sys_config
SET config_value = '/app/crawler'
WHERE config_key = 'crawler.basePath';
-- 如果配置不存在则插入
INSERT IGNORE INTO tb_sys_config (config_key, config_value, config_desc, created_at)
VALUES
('crawler.pythonPath', '/usr/bin/python3', 'Docker容器内Python路径', NOW()),
('crawler.basePath', '/app/crawler', 'Docker容器内爬虫脚本路径', NOW());
UPDATE _db_init_status
SET status = 'success'
WHERE script_name = '01-init-database.sql';
SELECT '✅ 数据库初始化完成!' AS message;
SELECT '默认用户: admin, 密码: admin123' AS tip;