优化单机部署,将数据库配置迁移到.env文件

This commit is contained in:
Lamber-maybe 2024-06-18 11:21:31 +08:00
parent 86fd419f6e
commit 54d83e8abb
2 changed files with 13 additions and 10 deletions

3
.env Normal file
View File

@ -0,0 +1,3 @@
MONGO_INITDB_ROOT_USERNAME=ScopeSentry
MONGO_INITDB_ROOT_PASSWORD=mongodb_password
REDIS_PASSWORD=redis_password

View File

@ -13,8 +13,8 @@ services:
ports: ports:
- "27017:27017" - "27017:27017"
environment: environment:
MONGO_INITDB_ROOT_USERNAME: "mongodb_username" MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME}
MONGO_INITDB_ROOT_PASSWORD: "mongodb_password" MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}
volumes: volumes:
- ./data/mongodb:/data/db - ./data/mongodb:/data/db
networks: networks:
@ -26,7 +26,7 @@ services:
restart: always restart: always
ports: ports:
- "6379:6379" - "6379:6379"
command: redis-server --requirepass redis_password command: redis-server --requirepass ${REDIS_PASSWORD}
volumes: volumes:
- ./data/redis/data:/data - ./data/redis/data:/data
healthcheck: healthcheck:
@ -51,11 +51,11 @@ services:
MONGODB_IP: scopesentry-mongodb MONGODB_IP: scopesentry-mongodb
MONGODB_PORT: 27017 MONGODB_PORT: 27017
DATABASE_NAME: ScopeSentry DATABASE_NAME: ScopeSentry
DATABASE_USER: "mongodb_username" DATABASE_USER: ${MONGO_INITDB_ROOT_USERNAME}
DATABASE_PASSWORD: "mongodb_password" DATABASE_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}
REDIS_IP: scopesentry-redis REDIS_IP: scopesentry-redis
REDIS_PORT: 6379 REDIS_PORT: 6379
REDIS_PASSWORD: "redis_password" REDIS_PASSWORD: ${REDIS_PASSWORD}
healthcheck: healthcheck:
test: ["CMD-SHELL", "curl -f http://127.0.0.1:8082 || exit 1"] test: ["CMD-SHELL", "curl -f http://127.0.0.1:8082 || exit 1"]
interval: 30s interval: 30s
@ -74,13 +74,13 @@ services:
TimeZoneName: Asia/Shanghai TimeZoneName: Asia/Shanghai
Mongodb_IP: 127.0.0.1 Mongodb_IP: 127.0.0.1
MONGODB_PORT: 27017 MONGODB_PORT: 27017
Mongodb_Username: "mongodb_username" Mongodb_Username: ${MONGO_INITDB_ROOT_USERNAME}
Mongodb_Password: "mongodb_password" Mongodb_Password: ${MONGO_INITDB_ROOT_PASSWORD}
Redis_IP: 127.0.0.1 Redis_IP: 127.0.0.1
Redis_PORT: 6379 Redis_PORT: 6379
Redis_Password: "redis_password" Redis_Password: ${REDIS_PASSWORD}
depends_on: depends_on:
redis: redis:
condition: service_healthy condition: service_healthy
scope-sentry: scope-sentry:
condition: service_healthy condition: service_healthy