实现 nacos 的分布式集群部署配置

This commit is contained in:
编码猿
2025-09-29 05:07:42 +08:00
parent ced7662d98
commit 04754a1f77
82 changed files with 991 additions and 62852 deletions

View File

@@ -1 +1,2 @@
docker-compose down && docker-compose up -d
docker-compose down && docker-compose up -d
docker compose down && docker compose up -d

View File

@@ -8,27 +8,32 @@ services:
- traefik-net
ports:
- "80:80"
- "8080:8080"
- "8880:8080"
# network_mode: "host" # 主机网络模式
volumes:
- ./traefik.yml:/etc/traefik/traefik.yml
- ./dynamic.yml:/etc/traefik/dynamic.yml # 动态配置文件
restart: always
whoami:
image: traefik/whoami
labels:
- "traefik.http.routers.whoami.rule=Host(`whoami.localhost`)"
# 2. Nacos 服务监听脚本
nacos-watcher:
user: "root"
privileged: true
image: node:24.8.0-alpine3.21
container_name: nacos-watcher
# network_mode: "host"
networks:
- traefik-net
working_dir: /app
volumes:
- ./:/app # 挂载当前目录到容器
command: sh -c "npm install && node src/index.js"
restart: always
# nacos-cluster-watcher:
# user: "root"
# privileged: true
# image: node:24.8.0-alpine3.21
# container_name: nacos-cluster-watcher
# # network_mode: "host"
# networks:
# - traefik-net
# working_dir: /app
# volumes:
# - ./:/app # 挂载当前目录到容器
# command: sh -c "npm install && node src/index.js"
# restart: always
networks:
traefik-net:

View File

@@ -1,5 +1,5 @@
{
"name": "traefik",
"name": "traefik-naco",
"version": "1.0.0",
"description": "",
"scripts": {

View File

@@ -4,6 +4,8 @@ module.exports = {
filePath: path.join(__dirname, '../../dynamic.yml'),
nacosApi: {
baseUrl: 'http://192.168.31.101:8848/nacos/v1/ns',
// baseUrl: 'http://192.168.31.101:8848/nacos/v3/admin/ns',
apiList: {
instanceInfo: '/instance/list',
serviceList: '/service/list',