Skip to content

Commit

Permalink
ci: 使用mariadb替换mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
liuruibin committed Jul 19, 2024
1 parent a2c1a2b commit a576cb5
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ pipeline {
steps {
dir('installer') {
script {
def images = ['mysql:8.0.38',
def images = ['mariadb:11.4.2',
'kafka:3.7.1',
'redis:7.2.5',
'minio:RELEASE.2024-05-07T06-41-25Z',
Expand All @@ -319,7 +319,7 @@ pipeline {
rm -rf images && mkdir images && cd images
docker save ${IMAGE_PREFIX}/metersphere-ce:${RELEASE} \\
${IMAGE_PREFIX}/kafka:3.7.1 \\
${IMAGE_PREFIX}/mysql:8.0.38 \\
${IMAGE_PREFIX}/mariadb:11.4.2 \\
${IMAGE_PREFIX}/redis:7.2.5 \\
${IMAGE_PREFIX}/minio:RELEASE.2024-05-07T06-41-25Z > metersphere.tar
cd ..
Expand All @@ -328,7 +328,7 @@ pipeline {
rm -rf enterprise && mkdir enterprise && cd enterprise
docker save ${IMAGE_PREFIX}/metersphere-ee:${RELEASE} \\
${IMAGE_PREFIX}/kafka:3.7.1 \\
${IMAGE_PREFIX}/mysql:8.0.38 \\
${IMAGE_PREFIX}/mariadb:11.4.2 \\
${IMAGE_PREFIX}/redis:7.2.5 \\
${IMAGE_PREFIX}/minio:RELEASE.2024-05-07T06-41-25Z > metersphere.tar
cd ..
Expand Down
33 changes: 33 additions & 0 deletions metersphere/docker-compose-mariadb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: "3"
services:
mysql:
image: ${MS_IMAGE_PREFIX}/mariadb:11.4.2
container_name: mysql
healthcheck:
test: ["CMD", "mariadb-admin", "ping", "-h", "localhost", "-uroot", "-p${MS_MYSQL_PASSWORD}"]
interval: 6s
timeout: 5s
retries: 50
environment:
MYSQL_DATABASE: ${MS_MYSQL_DB}
MYSQL_ROOT_PASSWORD: ${MS_MYSQL_PASSWORD}
TZ: "Asia/Shanghai"
ports:
- ${MS_MYSQL_PORT}:3306
volumes:
- ${MS_BASE}/metersphere/conf/my.cnf:/etc/mysql/conf.d/my.cnf
- ms-mariadb-data:/var/lib/mysql
networks:
- ms-network
restart: always
metersphere:
depends_on:
mysql:
condition: service_healthy

volumes:
ms-mariadb-data:
driver_opts:
type: none
device: ${MS_BASE}/metersphere/data/mariadb
o: bind
21 changes: 18 additions & 3 deletions msctl
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,27 @@ function generate_compose_files() {
if [ "${MS_INSTALL_MODE}" != "task-runner" ] && [ "${MS_INSTALL_MODE}" != "server" ]; then
# 是否使用外部数据库
if [ "${MS_EXTERNAL_MYSQL}" = "false" ]; then
mkdir -p ${MS_BASE}/metersphere/data/mysql
chmod 655 ${MS_BASE}/metersphere/conf/my.cnf
compose_files="${compose_files} -f docker-compose-mysql.yml"

database='mariadb'
# 升级查看是否是 mysql 还是 mariadb
if ["${INSTALL_TYPE}" == "upgrade"]; then
if [ -d "${MS_BASE}/metersphere/data/mysql" ];then
database='mysql'
fi
if [ -d "${MS_BASE}/metersphere/data/mariadb" ];then
database='mariadb'
fi
fi
# 全新安装的环境使用 mariadb
if [ "${INSTALL_TYPE}" == "install" ]; then
database='mariadb'
fi
mkdir -p ${MS_BASE}/metersphere/data/${database}
compose_files="${compose_files} -f docker-compose-${database}.yml"
# 中间件去掉 depends_on
if [ "${MS_INSTALL_MODE}" = "middleware" ]; then
sed -i -e '/metersphere/,+3d' ${MS_BASE}/metersphere/docker-compose-mysql.yml
sed -i -e '/metersphere/,+3d' ${MS_BASE}/metersphere/docker-compose-${database}.yml
fi
fi
# 是否使用外部 Kafka
Expand Down

0 comments on commit a576cb5

Please sign in to comment.