From fc01a6f26e2a3d7184329f81cbc8c42a560d3089 Mon Sep 17 00:00:00 2001 From: zhangsz Date: Fri, 17 Jan 2025 15:21:03 +0800 Subject: [PATCH] feat: deploy default config file --- build/bin/wfcsetup.sh | 49 ++++++++++++------- .../docker/mysql/conf.d/{ => default}/my.cnf | 0 .../docker/nacos/conf/application.properties | 34 ------------- .../nacos/conf/{ => default}/application.yml | 0 .../nginx/conf/{ => default}/nginx.conf | 0 .../redis/conf/{ => default}/redis.conf | 0 6 files changed, 32 insertions(+), 51 deletions(-) rename build/docker/mysql/conf.d/{ => default}/my.cnf (100%) delete mode 100644 build/docker/nacos/conf/application.properties rename build/docker/nacos/conf/{ => default}/application.yml (100%) rename build/docker/nginx/conf/{ => default}/nginx.conf (100%) rename build/docker/redis/conf/{ => default}/redis.conf (100%) diff --git a/build/bin/wfcsetup.sh b/build/bin/wfcsetup.sh index 980c35c..3116121 100755 --- a/build/bin/wfcsetup.sh +++ b/build/bin/wfcsetup.sh @@ -18,14 +18,19 @@ docker_my_conf_file=${docker_mysql_conf_d}/my.cnf wfc_jar_images=$(docker images --format "{{.Repository}}"|grep -E "docker-wfc-|docker_wfc-") wfc_modules_images=$(docker images --format "{{.Repository}}"|grep -E "docker-wfc-modules-|docker_wfc-modules-") -conf_dirs="${docker_work_dir}/conf - ${docker_work_dir}/wfc/gateway/conf - ${docker_work_dir}/wfc/auth/conf - ${docker_work_dir}/wfc/modules/system/conf - ${docker_work_dir}/wfc/modules/user/conf - ${docker_work_dir}/wfc/modules/job/conf - ${docker_work_dir}/wfc/modules/file/conf - ${docker_work_dir}/wfc/modules/payment/conf" +conf_dirs=" ${docker_work_dir}/conf + ${docker_work_dir}/redis/conf + ${docker_work_dir}/mysql/conf.d + ${docker_work_dir}/nacos/conf + ${docker_work_dir}/nginx/conf + ${docker_work_dir}/wfc/gateway/conf + ${docker_work_dir}/wfc/auth/conf + ${docker_work_dir}/wfc/modules/system/conf + ${docker_work_dir}/wfc/modules/user/conf + ${docker_work_dir}/wfc/modules/job/conf + ${docker_work_dir}/wfc/modules/file/conf + ${docker_work_dir}/wfc/modules/payment/conf + " case "$1" in env) @@ -35,14 +40,6 @@ case "$1" in if [ ! -d ${redis_work_dir}/data ]; then mkdir -p ${redis_work_dir}/data fi - if [ -d ${docker_work_dir}/mysql/data ]; then - chown -R 999:999 ${docker_work_dir}/mysql/data - fi - find ${docker_work_dir} -type d -exec chmod 775 {} \; - find ${docker_work_dir} -type f -exec chmod 664 {} \; - chown root:root ${docker_work_dir}/mysql/conf.d/my.cnf - chmod 600 ${docker_work_dir}/mysql/conf.d/my.cnf - chmod 1777 ${docker_work_dir}/mysql/tmp # setup system serivce cp -rf ${src_service_dir}/wfccontrol.service ${dst_service_dir}/ @@ -98,12 +95,30 @@ case "$1" in # nginx定义原始文件和临时文件 org_nginx_conf=${docker_work_dir}/nginx/conf/nginx.conf + tmp_intermediate_conf=${docker_work_dir}/nginx/conf/tmp_intermediate.conf tmp_nginx_conf=${docker_work_dir}/nginx/conf/tmp_nginx.conf # 使用sed命令替换proxy_pass行中的IP地址 - sed "s|proxy_pass http://.*/;|proxy_pass http://${GATEWAY_SERVER_IP}:${GATEWAY_SERVER_PORT}/;|" $org_nginx_conf > $tmp_nginx_conf + # Define intermediate temporary nginx configuration file + # Replace the proxy_pass line with the correct GATEWAY_SERVER_IP and GATEWAY_SERVER_PORT + sed "s|proxy_pass http://.*:8080/;|proxy_pass http://${GATEWAY_SERVER_IP}:${GATEWAY_SERVER_PORT}/;|" $org_nginx_conf > $tmp_intermediate_conf + + # Replace the IP address and port for the file server in the nginx configuration + sed "s|proxy_pass http://.*:9201/;|proxy_pass http://${GATEWAY_SERVER_IP}:${WFC_FILE_PORT}/;|" $tmp_intermediate_conf > $tmp_nginx_conf + + # Remove the intermediate temporary file and move the final configuration + rm $tmp_intermediate_conf mv $tmp_nginx_conf $org_nginx_conf + # chown and chmod for all docker work directory + if [ -d ${docker_work_dir}/mysql/data ]; then + chown -R 999:999 ${docker_work_dir}/mysql/data + fi + find ${docker_work_dir} -type d -exec chmod 775 {} \; + find ${docker_work_dir} -type f -exec chmod 664 {} \; + chown root:root ${docker_work_dir}/mysql/conf.d/my.cnf + chmod 600 ${docker_work_dir}/mysql/conf.d/my.cnf + chmod 1777 ${docker_work_dir}/mysql/tmp ;; initdb) # init database diff --git a/build/docker/mysql/conf.d/my.cnf b/build/docker/mysql/conf.d/default/my.cnf similarity index 100% rename from build/docker/mysql/conf.d/my.cnf rename to build/docker/mysql/conf.d/default/my.cnf diff --git a/build/docker/nacos/conf/application.properties b/build/docker/nacos/conf/application.properties deleted file mode 100644 index 0369011..0000000 --- a/build/docker/nacos/conf/application.properties +++ /dev/null @@ -1,34 +0,0 @@ -spring.datasource.platform=mysql -db.num=1 -db.url.0=jdbc:mysql://wfc-mysql:3306/wfc_config_db?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC -db.user=root -db.password=123456 - -nacos.naming.empty-service.auto-clean=true -nacos.naming.empty-service.clean.initial-delay-ms=50000 -nacos.naming.empty-service.clean.period-time-ms=30000 -# nacos.server.ip=${NACOS_SERVER_IP} -# nacos.server.port=${NACOS_SERVER_PORT} - -management.endpoints.web.exposure.include=* - -management.metrics.export.elastic.enabled=false -management.metrics.export.influx.enabled=false - -server.tomcat.accesslog.enabled=true -server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i - -server.tomcat.basedir=/home/wfc/nacos/tomcat/logs - -nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/** - -nacos.core.auth.system.type=nacos -nacos.core.auth.enabled=false -nacos.core.auth.default.token.expire.seconds=18000 -nacos.core.auth.default.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789 -nacos.core.auth.caching.enabled=true -nacos.core.auth.enable.userAgentAuthWhite=false -nacos.core.auth.server.identity.key=serverIdentity -nacos.core.auth.server.identity.value=security - -nacos.istio.mcp.server.enabled=false diff --git a/build/docker/nacos/conf/application.yml b/build/docker/nacos/conf/default/application.yml similarity index 100% rename from build/docker/nacos/conf/application.yml rename to build/docker/nacos/conf/default/application.yml diff --git a/build/docker/nginx/conf/nginx.conf b/build/docker/nginx/conf/default/nginx.conf similarity index 100% rename from build/docker/nginx/conf/nginx.conf rename to build/docker/nginx/conf/default/nginx.conf diff --git a/build/docker/redis/conf/redis.conf b/build/docker/redis/conf/default/redis.conf similarity index 100% rename from build/docker/redis/conf/redis.conf rename to build/docker/redis/conf/default/redis.conf