添加构建脚本;

This commit is contained in:
terrfly 2024-03-05 14:14:47 +08:00
parent 7e8bcedbc4
commit 56405fa3d2
6 changed files with 2452 additions and 0 deletions

26
docs/install/config.sh Normal file
View File

@ -0,0 +1,26 @@
#! /bin/sh
#exec 2>>build.log ##编译过程打印到日志文件中
## 配置文件 .Power by terrfly
# 【项目根目录的地址】 该地址下会包含: nginx/mysql/mq/redis等文件
rootDir="/jeepayhomes"
# 【mysql密码】建议更改
mysql_pwd="jeepaydb123456"
#当前路径, 不要更改参数。
currentPath=`pwd`

View File

@ -0,0 +1,74 @@
[client]
#password = your_password
port = 3306
# Docker下无需设置 目录
# socket = /tmp/mysql.sock
[mysqld]
port = 3306
# Docker必须要设置secure_file_priv
secure_file_priv=/var/lib/mysql
# Docker下无需设置 目录
# socket = /tmp/mysql.sock
# datadir = /usr/local/mysql/var
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
thread_cache_size = 8
tmp_table_size = 16M
performance_schema_max_table_instances = 500
explicit_defaults_for_timestamp = true
#skip-networking
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535
default_authentication_plugin = mysql_native_password
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
binlog_expire_logs_seconds = 864000
early-plugin-load = ""
default_storage_engine = InnoDB
innodb_file_per_table = 1
# Docker下无需设置 目录
# innodb_data_home_dir = /usr/local/mysql/var
# innodb_data_file_path = ibdata1:10M:autoextend
# innodb_log_group_home_dir = /usr/local/mysql/var
innodb_buffer_pool_size = 16M
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
sql-mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout

View File

@ -0,0 +1,87 @@
# 官方默认配置文件, 下载地址: https://nginx.org/download/nginx-1.18.0.tar.gz
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# 运营平台
server {
listen 19217; #监听端口,若监听域名请添加 server_name
root /usr/share/nginx/html/jeepaymanager;
index index.html index.htm;
#解决vue刷新404问题
try_files $uri $uri/ /index.html;
# 主页面不允许缓存(避免项目升级 空白页的问题)
location /index.html {
add_header Expires -1;
add_header Cache-Control no-cache;
}
location /api/
{
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:9217;
# 启用支持websocket连接
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
# 商户平台
server {
listen 19218; #监听端口,若监听域名请添加 server_name
root /usr/share/nginx/html/jeepaymerchant;
index index.html index.htm;
#解决vue刷新404问题
try_files $uri $uri/ /index.html;
# 主页面不允许缓存(避免项目升级 空白页的问题)
location /index.html {
add_header Expires -1;
add_header Cache-Control no-cache;
}
location /api/
{
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:9218;
# 启用支持websocket连接
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
# 支付网关
server {
listen 19216; #监听端口,若监听域名请添加 server_name
location /
{
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:9216;
}
}
}

File diff suppressed because it is too large Load Diff

177
docs/install/install.sh Normal file
View File

@ -0,0 +1,177 @@
#! /bin/sh
#exec 2>>build.log ##编译过程打印到日志文件中
## 自动构建,并下载基础文件 .Power by terrfly
#引入config
. ./config.sh
# 需要注意:
# 1. root用户登录
# 2. 请务必包含 docker环境 和 git环境
# 第0步提示信息
echo "请确认当前是全新服务器安装, 是否继续?"
echo "(Please confirm if it is a brand new server installation, do you want to continue?)"
echo " [yes/no] ?"
read useryes
if [ -z "$useryes" ] || [ $useryes != 'yes' ]
then
echo 'good bye'
exit 0
fi
# 第1步创建基本目录
echo "[1] 创建项目根目录($rootDir).... "
mkdir $rootDir/nginx -p
mkdir $rootDir/nginx/conf -p
mkdir $rootDir/nginx/conf.d -p
mkdir $rootDir/nginx/html -p
mkdir $rootDir/nginx/logs -p
mkdir $rootDir/mysql -p
mkdir $rootDir/mysql/config -p
mkdir $rootDir/mysql/log -p
mkdir $rootDir/mysql/data -p
# mkdir $rootDir/activemq -p
mkdir $rootDir/redis -p
mkdir $rootDir/redis/config -p
mkdir $rootDir/redis/data -p
mkdir $rootDir/service/configs -p
mkdir $rootDir/service/uploads -p
mkdir $rootDir/service/logs -p
mkdir $rootDir/sources -p
echo "[1] Done. "
# 第2步拉取项目源代码 || 拉取脚本文件
echo "[2] 拉取项目源代码文件.... "
cd $rootDir/sources
git clone https://gitee.com/jeequan/jeepay.git
echo "[2] Done. "
# 创建一个 bridge网络
docker network create jeepay-net
# 第3步下载mysql官方镜像 & 启动
echo "[3] 下载并启动mysql容器.... "
# 将Mysql的配置文件复制到对应的映射目录下
cd $currentPath && cp ./include/my.cnf $rootDir/mysql/config/my.cnf
# 镜像启动
docker run -p 3306:3306 --name mysql8 --network=jeepay-net \
--restart=always --privileged=true \
-v /etc/localtime:/etc/localtime:ro \
-v $rootDir/mysql/log:/var/log/mysql \
-v $rootDir/mysql/data:/var/lib/mysql \
-v $rootDir/mysql/config:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=$mysql_pwd \
-d mysql:8.0.25
# 容器重启
docker restart mysql8
# 避免未启动完成或出现错误: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
echo "等待重启mysql容器....... "
sleep 10
echo "[3] 初始化数据导入 ...... "
# 创建数据库 && 导入数据
echo "CREATE DATABASE jeepaydb DEFAULT CHARACTER SET utf8mb4" | docker exec -i mysql8 mysql -uroot -p$mysql_pwd
docker exec -i mysql8 sh -c "mysql -uroot -p$mysql_pwd --default-character-set=utf8mb4 jeepaydb" < $rootDir/sources/jeepay/docs/sql/init.sql
echo "[3] Done. "
# 第4步下载redis官方镜像 & 启动
echo "[4] 下载并启动redis容器.... "
# 将配置文件复制到对应的映射目录下
cd $currentPath && cp ./include/redis.conf $rootDir/redis/config/redis.conf
# 镜像启动
docker run -p 6379:6379 --name redis6 --network=jeepay-net \
--restart=always --privileged=true \
-v /etc/localtime:/etc/localtime:ro \
-v $rootDir/redis/config/redis.conf:/etc/redis/redis.conf \
-v $rootDir/redis/data:/data \
-d redis:6.2.14 redis-server /etc/redis/redis.conf
echo "[4] Done. "
# 第5步下载并启动activemq容器
echo "[5] 下载并启动activemq容器.... "
docker run -p 8161:8161 -p 61616:61616 --name activemq5 --network=jeepay-net \
--restart=always \
-v /etc/localtime:/etc/localtime:ro \
-d jeepay/activemq:5.15.16
echo "[5] Done. "
# 第6步下载并启动 java 项目
# 复制java配置文件
cd $rootDir/service/configs/ && cp -r $rootDir/sources/jeepay/conf/* .
echo "[6.1] 下载并启动 java 项目 [ jeepaymanager ] .... "
# 运行 java项目
docker run -itd --name jeepaymanager --network=jeepay-net \
-p 9217:9217 \
-v $rootDir/service/logs:/jeepayhomes/service/logs \
-v $rootDir/service/uploads:/jeepayhomes/service/uploads \
-v $rootDir/service/configs/manager/application.yml:/jeepayhomes/service/app/application.yml \
-d jeepay/jeepay-manager:v2.2.2
echo "[6.2] 下载并启动 java 项目 [ jeepaymerchant ] .... "
# 运行 java项目
docker run -itd --name jeepaymerchant --network=jeepay-net \
-p 9218:9218 \
-v $rootDir/service/logs:/jeepayhomes/service/logs \
-v $rootDir/service/uploads:/jeepayhomes/service/uploads \
-v $rootDir/service/configs/merchant/application.yml:/jeepayhomes/service/app/application.yml \
-d jeepay/jeepay-merchant:v2.2.2
echo "[6.3] 下载并启动 java 项目 [ jeepaypayment ] .... "
# 运行 java项目
docker run -itd --name jeepaypayment --network=jeepay-net \
-p 9216:9216 \
-v $rootDir/service/logs:/jeepayhomes/service/logs \
-v $rootDir/service/uploads:/jeepayhomes/service/uploads \
-v $rootDir/service/configs/payment/application.yml:/jeepayhomes/service/app/application.yml \
-d jeepay/jeepay-payment:v2.2.2
echo "[6] Done. "
echo "[7] 下载并启动 nginx .... "
cd $rootDir/nginx/html
wget https://gitee.com/jeequan/jeepay-ui/releases/download/v1.10.0/html.tar.gz
tar -vxf html.tar.gz
# 将配置文件复制到对应的映射目录下
cd $currentPath && cp ./include/nginx.conf $rootDir/nginx/conf/nginx.conf
docker run --name nginx118 \
--restart=always --privileged=true --net=host \
-v /etc/localtime:/etc/localtime:ro \
-v $rootDir/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v $rootDir/nginx/conf/conf.d:/etc/nginx/conf.d \
-v $rootDir/nginx/logs:/var/log/nginx \
-v $rootDir/nginx/html:/usr/share/nginx/html \
-d nginx:1.18.0
echo "[7] Done. "
docker logs -f jeepaypayment

31
docs/install/uninstall.sh Normal file
View File

@ -0,0 +1,31 @@
#! /bin/sh
#exec 2>>build.log ##编译过程打印到日志文件中
## 项目卸载 .Power by terrfly
#引入config
. ./config.sh
# 第0步提示信息
echo "请确认全部卸载, 是否继续?"
echo "(Confirm uninstallation, do you want to continue?)"
echo " [yes/no] ?"
read useryes
if [ -z "$useryes" ] || [ $useryes != 'yes' ]
then
echo 'good bye'
exit 0
fi
docker stop nginx118 && docker rm nginx118
docker stop jeepaymanager && docker rm jeepaymanager
docker stop jeepaymerchant && docker rm jeepaymerchant
docker stop jeepaypayment && docker rm jeepaypayment
docker stop mysql8 && docker rm mysql8
docker stop redis6 && docker rm redis6
docker stop activemq5 && docker rm activemq5
rm -rf $rootDir