Compare commits

...

2 Commits

Author SHA1 Message Date
cxhello 26cc6b6056
refactor: Compatible with Nacos multiple versions (#464) 2025-07-24 19:40:33 +08:00
cxhello a3795ac461
feat: add Dockerfile 9848&8080 expose (#461)
* feat: add Dockerfile 9848-9849 expose

* feat: add Dockerfile 9848-9849 expose

* add Dockerfile 9848&8080 expose
2025-07-03 09:40:58 +08:00
6 changed files with 44 additions and 14 deletions

View File

@ -72,11 +72,8 @@ Run the following command
* Standalone Mysql
```powershell
# Using mysql 5.7
docker-compose -f example/standalone-mysql-5.7.yaml up
# Using mysql 8
docker-compose -f example/standalone-mysql-8.yaml up
cd example
./mysql-init.sh && docker-compose -f standalone-mysql.yaml up
```
* Standalone Nacos Cluster

View File

@ -50,11 +50,8 @@
* Standalone Mysql
```powershell
# Using mysql 5.7
docker-compose -f example/standalone-mysql-5.7.yaml up
# Using mysql 8
docker-compose -f example/standalone-mysql-8.yaml up
cd example
./mysql-init.sh && docker-compose -f standalone-mysql.yaml up
```
* docker单节点部署集群模式

View File

@ -46,4 +46,5 @@ RUN mkdir -p logs \
&& chmod +x bin/docker-startup.sh
EXPOSE 8848
EXPOSE 9848 8080
ENTRYPOINT ["sh","bin/docker-startup.sh"]

View File

@ -45,4 +45,5 @@ RUN mkdir -p logs \
RUN chmod +x bin/docker-startup.sh
EXPOSE 8848
EXPOSE 9848 8080
ENTRYPOINT ["bin/docker-startup.sh"]

33
example/mysql-init.sh Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
set -e
# 加载 NACOS_VERSION
source .env
CLEAN_VERSION=${NACOS_VERSION#v}
SCHEMA_URL="https://raw.githubusercontent.com/alibaba/nacos/${CLEAN_VERSION}/distribution/conf/mysql-schema.sql"
TARGET_DIR="./mysql-init"
VERSIONED_FILE="${TARGET_DIR}/${NACOS_VERSION}-mysql-schema.sql"
FINAL_FILE="${TARGET_DIR}/mysql-schema.sql"
# 创建目录
mkdir -p "${TARGET_DIR}"
# 下载 schema 文件
echo "⬇️ Downloading MySQL schema for Nacos ${CLEAN_VERSION}..."
curl -sSL "$SCHEMA_URL" -o "${VERSIONED_FILE}"
# 校验下载
if [ ! -s "${VERSIONED_FILE}" ]; then
echo "❌ Failed to download schema file from $SCHEMA_URL"
exit 1
fi
# 拷贝为标准文件名供 MySQL 初始化使用
cp "${VERSIONED_FILE}" "${FINAL_FILE}"
# 删除原始版本号文件
rm -f "${VERSIONED_FILE}"
echo "✅ Downloaded and prepared: ${FINAL_FILE}"

View File

@ -17,14 +17,15 @@ services:
restart: always
mysql:
container_name: mysql
build:
context: .
dockerfile: ./image/mysql/8/Dockerfile
image: example/mysql:8.0.30
image: mysql:8.0.30
env_file:
- ../env/mysql.env
volumes:
- ./mysql:/var/lib/mysql
- ./mysql-init:/docker-entrypoint-initdb.d/
command:
--character-set-server=utf8mb4
--collation-server=utf8mb4_unicode_ci
ports:
- "3306:3306"
healthcheck: