Files
PropertyDeployment/prod-env/docker-compose.yml
2025-12-09 20:22:03 +08:00

716 lines
21 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#todo 当前开放了3306和6379 生产环境请关闭
services:
# zookeeper 配置
zookeeper:
image: bitnami/zookeeper:3.9
container_name: zookeeper
restart: unless-stopped
user: root
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
- ZK_LOG_LEVEL=WARN
- TZ=Asia/Bangkok
labels:
com.description: "物业 物联网 后端 zookeeper 服务"
com.maintainer: "anfioo <anfioozys@gmail.com>"
com.module: "backend zookeeper"
volumes:
- zookeeper-data:/bitnami/zookeeper/data
- zookeeper-conf:/bitnami/zookeeper/conf
- zookeeper-logs:/bitnami/zookeeper/logs
command: |
sh -c '
mkdir -p /bitnami/zookeeper/conf /bitnami/zookeeper/logs &&
{
echo "# Root logger";
echo "log4j.rootLogger=${ZK_LOG_LEVEL:-DEBUG}, CONSOLE, ROLLINGFILE";
echo "";
echo "log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender";
echo "log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout";
echo "log4j.appender.CONSOLE.layout.ConversionPattern=[%d] %-5p %c:%L - %m%n";
echo "";
echo "log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender";
echo "log4j.appender.ROLLINGFILE.File=/bitnami/zookeeper/logs/zookeeper.log";
echo "log4j.appender.ROLLINGFILE.MaxFileSize=${ZK_LOG_MAX_SIZE:-20MB}";
echo "log4j.appender.ROLLINGFILE.MaxBackupIndex=${ZK_LOG_BACKUP_COUNT:-5}";
echo "log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout";
echo "log4j.appender.ROLLINGFILE.layout.ConversionPattern=[%d] %-5p %c:%L - %m%n";
} > /bitnami/zookeeper/conf/log4j.properties &&
touch /bitnami/zookeeper/logs/zookeeper.log &&
echo " Generated /bitnami/zookeeper/conf/log4j.properties" &&
exec /opt/bitnami/scripts/zookeeper/entrypoint.sh /opt/bitnami/scripts/zookeeper/run.sh
'
networks:
- anfioonet
depends_on:
- volume-helper-ssh
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "3"
# kafka 配置
kafka:
image: bitnami/kafka:3.6.2
container_name: kafka
restart: unless-stopped
user: root
environment:
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
- KAFKA_LOG_LEVEL=WARN
- ALLOW_PLAINTEXT_LISTENER=yes
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=PLAINTEXT:PLAINTEXT
- KAFKA_CFG_INTER_BROKER_LISTENER_NAME=PLAINTEXT
- TZ=Asia/Bangkok
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "3"
labels:
com.description: "物业 物联网 后端 kafka 服务"
com.maintainer: "anfioo <anfioozys@gmail.com>"
com.module: "backend kafka"
volumes:
- kafka-data:/bitnami/kafka/data
- kafka-conf:/bitnami/kafka/conf
- kafka-logs:/bitnami/kafka/logs
command: |
sh -c '
mkdir -p /bitnami/kafka/conf /bitnami/kafka/logs &&
{
echo "# Root logger level: INFO, output to console and file";
echo "log4j.rootLogger=${KAFKA_LOG_LEVEL:-DEBUG}, stdout, file";
echo "";
echo "log4j.appender.stdout=org.apache.log4j.ConsoleAppender";
echo "log4j.appender.stdout.layout=org.apache.log4j.PatternLayout";
echo "log4j.appender.stdout.layout.ConversionPattern=[%d] %-5p %c:%L - %m%n";
echo "";
echo "log4j.appender.file=org.apache.log4j.RollingFileAppender";
echo "log4j.appender.file.File=/bitnami/kafka/logs/server.log";
echo "log4j.appender.file.MaxFileSize=${KAFKA_LOG_MAX_SIZE:-20MB}";
echo "log4j.appender.file.MaxBackupIndex=${KAFKA_LOG_BACKUP_COUNT:-5}";
echo "log4j.appender.file.layout=org.apache.log4j.PatternLayout";
echo "log4j.appender.file.layout.ConversionPattern=[%d] %-5p %c:%L - %m%n";
} > /opt/bitnami/kafka/config/log4j.properties &&
touch /bitnami/kafka/logs/server.log &&
echo " Generated /opt/bitnami/kafka/config/log4j.properties" &&
exec /opt/bitnami/scripts/kafka/entrypoint.sh /opt/bitnami/scripts/kafka/run.sh
'
depends_on:
- volume-helper-ssh
- zookeeper
networks:
- anfioonet
# mqtt 配置
mqtt:
image: eclipse-mosquitto:2.0
container_name: mqtt
restart: unless-stopped
volumes:
- mqtt-data:/mosquitto/data
- mqtt-config:/mosquitto/config
- mqtt-log:/mosquitto/log
environment:
- TZ=Asia/Bangkok
- MQTT_USERNAME=${MQTT_USERNAME}
- MQTT_PASSWORD=${MQTT_PASSWORD}
labels:
com.description: "物联网 后端 mqtt 服务"
com.maintainer: "anfioo <anfioozys@gmail.com>"
com.module: "backend mqtt"
command: >
sh -c "
mkdir -p /mosquitto/config /mosquitto/data /mosquitto/log &&
# 动态生成配置文件
echo 'persistence true' > /mosquitto/config/mosquitto.conf &&
echo 'persistence_location /mosquitto/data/' >> /mosquitto/config/mosquitto.conf &&
echo 'log_dest file /mosquitto/log/mosquitto.log' >> /mosquitto/config/mosquitto.conf &&
echo 'allow_anonymous false' >> /mosquitto/config/mosquitto.conf &&
echo 'password_file /mosquitto/config/passwordfile' >> /mosquitto/config/mosquitto.conf &&
echo 'listener 1883' >> /mosquitto/config/mosquitto.conf &&
echo '${MQTT_USERNAME}:${MQTT_PASSWORD}' > /mosquitto/config/passwordfile &&
exec mosquitto -c /mosquitto/config/mosquitto.conf
"
networks:
- anfioonet
depends_on:
- volume-helper-ssh
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "3"
# mysql 配置
mysql:
image: mysql:8.0
container_name: mysql
restart: unless-stopped
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- TZ=Asia/Bangkok
labels:
com.description: "物业 物联网 后端 mysql 服务"
com.maintainer: "anfioo <anfioozys@gmail.com>"
com.module: "backend mysql"
volumes:
- mysql-conf:/etc/mysql
- mysql-data:/var/lib/mysql
- mysql-log:/var/log/mysql
- mysql-files:/var/lib/mysql-files
# 挂载 SQL 文件到初始化目录
- ../resources/mysql/${DB_USE}:/docker-entrypoint-initdb.d
command: |
sh -c '
mkdir -p /etc/mysql /var/log/mysql /var/lib/mysql-files &&
{
echo "[client]";
echo "default-character-set=utf8mb4";
echo "[mysql]";
echo "default-character-set=utf8mb4";
echo "[mysqld]";
echo "server-id = 1";
echo "log-bin = mysql-bin";
echo "binlog_expire_logs_seconds = 2592000";
echo "sql_mode = \"STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\"";
echo "max_connections = 300";
echo "symbolic-links = 0";
echo "default-time_zone = \"+7:00\"";
echo "lower_case_table_names=1";
echo "innodb_buffer_pool_size = 24G";
echo "innodb_buffer_pool_instances = 6";
echo "innodb_log_file_size = 1G";
echo "innodb_log_buffer_size = 128M";
echo "tmp_table_size = 256M";
echo "max_heap_table_size = 256M";
echo "table_open_cache = 4000";
echo "table_definition_cache = 2000";
echo "innodb_flush_method = O_DIRECT";
echo "innodb_flush_log_at_trx_commit = 2";
echo "innodb_io_capacity = 200";
echo "innodb_io_capacity_max = 400";
echo "thread_cache_size = 64";
echo "innodb_thread_concurrency = 0";
echo "innodb_read_io_threads = 8";
echo "innodb_write_io_threads = 8";
echo "slow_query_log = 1";
echo "slow_query_log_file = /var/log/mysql/slow.log";
echo "long_query_time = 2";
echo "character-set-server = utf8mb4";
echo "collation-server = utf8mb4_general_ci";
echo "skip-name-resolve";
} > /etc/mysql/my.cnf &&
echo "Generated /etc/mysql/my.cnf" &&
exec docker-entrypoint.sh mysqld
'
networks:
- anfioonet
depends_on:
- volume-helper-ssh
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "3"
# redis 配置
redis:
image: redis:7.2-alpine
container_name: redis
restart: unless-stopped
environment:
- REDIS_PASSWORD=${REDIS_PASSWORD} # 可修改密码
- TZ=Asia/Bangkok
ports:
- "6379:6379"
labels:
com.description: "物业 物联网 后端 redis 服务"
com.maintainer: "anfioo <anfioozys@gmail.com>"
com.module: "backend redis"
volumes:
- redis-conf:/usr/local/etc/redis # 存配置
- redis-data:/data # 存数据与日志
command: |
sh -c '
mkdir -p /usr/local/etc/redis /data/logs &&
# 初始化 redis.conf
{
echo "bind 0.0.0.0";
echo "port 6379";
echo "protected-mode yes";
echo "appendonly yes";
echo "maxmemory 64gb";
echo "maxmemory-policy allkeys-lru";
echo "requirepass ${REDIS_PASSWORD}";
echo "dir /data";
echo "logfile /data/logs/redis-$(date +%F).log";
} > /usr/local/etc/redis/redis.conf &&
# 启动后台日志轮换任务(每天 00:00 切换)
(
while true; do
sleep $((86400 - $(date +%s) % 86400)); # 等待到下一个午夜
NEW_LOG="/data/logs/redis-$(date +%F).log"
redis-cli -a ${REDIS_PASSWORD} config set logfile "$NEW_LOG" >/dev/null 2>&1 || true
done
) &
# 启动 Redis
exec redis-server /usr/local/etc/redis/redis.conf
'
networks:
- anfioonet
depends_on:
- volume-helper-ssh
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "3"
micro-community-boot:
build:
context: ../resources/MicroCommunity # 指向 Dockerfile 所在目录
dockerfile: Dockerfile
container_name: micro-community-boot
restart: unless-stopped
networks:
- anfioonet
ports:
- "8008:8008"
labels:
com.description: "物业 后端 服务 spring boot 2"
com.maintainer: "anfioo <anfioozys@gmail.com>"
com.module: "backend"
environment:
REDIS_PASSWORD: ${REDIS_PASSWORD}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
TZ: Asia/Bangkok
volumes:
- backend-property-logs:/logs
- backend-property-data:/jar
depends_on:
- volume-helper-ssh
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "3"
micro-community-iot:
build:
context: ../resources/MicroCommunityIot # 指向 Dockerfile 所在目录
dockerfile: Dockerfile
container_name: micro-community-iot
restart: unless-stopped
networks:
- anfioonet
ports:
- "9999:9999"
- "20011:20011"
labels:
com.description: "物联网端 后端 服务 spring boot 2"
com.maintainer: "anfioo <anfioozys@gmail.com>"
com.module: "backend"
environment:
REDIS_PASSWORD: ${REDIS_PASSWORD}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MQTT_PASSWORD: ${MQTT_PASSWORD}
MQTT_USERNAME: ${MQTT_USERNAME}
TZ: Asia/Bangkok
volumes:
- backend-iot-logs:/logs
- backend-iot-data:/jar
depends_on:
- volume-helper-ssh
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "3"
micro-community-web:
build:
context: ../resources/Web/MicroCommunityWeb
dockerfile: Dockerfile
container_name: micro-community-web
restart: unless-stopped
ports:
- "8111:8111" # 宿主机端口:容器端口
labels:
com.description: "物业端 Web 服务Nginx 静态前端)"
com.maintainer: "anfioo <anfioozys@gmail.com>"
com.module: "frontend"
volumes:
# 挂载 Docker 卷用于持久化
- web-property-data:/MicroCommunityWeb
- web-property-conf:/etc/nginx
environment:
TZ: Asia/Bangkok
networks:
- anfioonet
depends_on:
- volume-helper-ssh
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "3"
micro-community-iot-web:
build:
context: ../resources/Web/MicroCommunityIotWeb
dockerfile: Dockerfile
container_name: micro-community-iot-web
restart: unless-stopped
environment:
TZ: Asia/Bangkok
ports:
- "8112:8112" # 宿主机端口:容器端口
labels:
com.description: "物联网端 Web 服务Nginx 静态前端)"
com.maintainer: "anfioo <anfioozys@gmail.com>"
com.module: "frontend"
volumes:
# 挂载 Docker 卷用于持久化
- web-iot-data:/MicroCommunityIotWeb
- web-iot-config:/etc/nginx
networks:
- anfioonet
depends_on:
- volume-helper-ssh
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "3"
wechat-owner-service-web:
build:
context: ../resources/Web/WechatOwnerService
dockerfile: Dockerfile
container_name: wechat-owner-service-web
environment:
TZ: Asia/Bangkok
restart: unless-stopped
labels:
com.description: "微信业主端 Web 服务 H5页面Nginx 静态前端)"
com.maintainer: "anfioo <anfioozys@gmail.com>"
com.module: "frontend"
ports:
- "8113:8113" # 宿主机端口:容器端口
volumes:
# 挂载 Docker 卷用于持久化
- web-property-owner-data:/WechatOwnerService
- web-property-owner-conf:/etc/nginx
networks:
- anfioonet
depends_on:
- volume-helper-ssh
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "3"
property-app-web:
build:
context: ../resources/Web/PropertyApp
dockerfile: Dockerfile
container_name: property-app-web
environment:
TZ: Asia/Bangkok
restart: unless-stopped
labels:
com.description: "微信员工端 Web 服务 H5页面Nginx 静态前端)"
com.maintainer: "anfioo <anfioozys@gmail.com>"
com.module: "frontend"
ports:
- "8114:8114" # 宿主机端口:容器端口
volumes:
# 挂载 Docker 卷用于持久化
- web-property-staff-data:/PropertyApp
- web-property-staff-conf:/etc/nginx
networks:
- anfioonet
depends_on:
- volume-helper-ssh
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "3"
volume-helper-ssh:
build:
context: ../resources/VolumeHelperSSH
dockerfile: Dockerfile
args:
PASSWORD: ${VOLUME_HELPER_SSH_PASSWORD} # 可自定义 root 密码
container_name: volume-helper-ssh
restart: unless-stopped
environment:
TZ: Asia/Bangkok
labels:
com.description: "容器帮助者"
com.maintainer: "anfioo <anfioozys@gmail.com>"
com.module: "frontend"
ports:
- "2222:22" # 宿主机端口:容器端口
volumes:
# 本地挂载目录
- /docker-mount:/mount
- ${DEPLOYMENT_USE}:/PropertyDeployment
# Docker 卷挂载
- web-property-owner-data:/volumes/data/web-property-owner-data
- web-property-owner-conf:/volumes/conf/web-property-owner-config
- web-property-staff-data:/volumes/data/web-property-staff-data
- web-property-staff-conf:/volumes/conf/web-property-staff-config
- web-iot-data:/volumes/data/web-iot-data
- web-iot-config:/volumes/conf/web-iot-config
- web-property-data:/volumes/data/web-property-data
- web-property-conf:/volumes/conf/web-property-config
- zookeeper-data:/volumes/data/zookeeper-data
- zookeeper-conf:/volumes/conf/zookeeper-conf
- kafka-data:/volumes/data/kafka-data
- kafka-conf:/volumes/conf/kafka-conf
- mqtt-data:/volumes/data/mqtt-data
- mqtt-config:/volumes/conf/mqtt-config
- mqtt-log:/volumes/logs/mqtt-log
- mysql-conf:/volumes/conf/mysql-conf
- mysql-data:/volumes/data/mysql-data
- mysql-log:/volumes/logs/mysql-log
- mysql-files:/volumes/data/mysql-files
- redis-conf:/volumes/conf/redis-conf
- redis-data:/volumes/data/redis-data
- backend-property-logs:/volumes/logs/backend-property-logs
- backend-iot-logs:/volumes/logs/backend-iot-logs
- backend-iot-data:/volumes/data/backend-iot-data
- backend-property-data:/volumes/data/backend-property-data
- kafka-logs:/volumes/logs/kafka-logs
- zookeeper-logs:/volumes/logs/zookeeper-logs
networks:
- anfioonet
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "3"
volumes:
web-property-owner-data:
driver: local
driver_opts:
type: none
device: ${DEPLOYMENT_USE}/resources/Web/WechatOwnerService/html
o: bind
web-property-owner-conf:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/web-property-owner-conf
o: bind
web-iot-data:
driver: local
driver_opts:
type: none
device: ${DEPLOYMENT_USE}/resources/Web/MicroCommunityIotWeb/html
o: bind
web-iot-config:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/web-iot-config
o: bind
web-property-data:
driver: local
driver_opts:
type: none
device: ${DEPLOYMENT_USE}/resources/Web/MicroCommunityWeb/html
o: bind
web-property-conf:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/web-property-conf
o: bind
web-property-staff-data:
driver: local
driver_opts:
type: none
device: ${DEPLOYMENT_USE}/resources/Web/PropertyApp/html
o: bind
web-property-staff-conf:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/web-property-staff-conf
o: bind
zookeeper-data:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/zookeeper-data
o: bind
zookeeper-conf:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/zookeeper-conf
o: bind
zookeeper-logs:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/zookeeper-logs
o: bind
kafka-data:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/kafka-data
o: bind
kafka-conf:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/kafka-conf
o: bind
kafka-logs:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/kafka-logs
o: bind
mqtt-data:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/mqtt-data
o: bind
mqtt-config:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/mqtt-config
o: bind
mqtt-log:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/mqtt-log
o: bind
mysql-data:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/mysql-data
o: bind
mysql-conf:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/mysql-conf
o: bind
mysql-log:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/mysql-log
o: bind
mysql-files:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/mysql-files
o: bind
redis-data:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/redis-data
o: bind
redis-conf:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/redis-conf
o: bind
backend-property-logs:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/backend-property-logs
o: bind
backend-property-data:
driver: local
driver_opts:
type: none
device: ${DEPLOYMENT_USE}/resources/MicroCommunity
o: bind
backend-iot-logs:
driver: local
driver_opts:
type: none
device: ${VOLUMES_USE}/backend-iot-logs
o: bind
backend-iot-data:
driver: local
driver_opts:
type: none
device: ${DEPLOYMENT_USE}/resources/MicroCommunityIot
o: bind
networks:
anfioonet:
name: anfioonet
driver: bridge