feat: docker-compose

V0.5.x
gaoyoulong 2024-02-22 13:46:48 +08:00
parent 69845a7638
commit ca61e03202
2 changed files with 21 additions and 33 deletions

View File

@ -14,7 +14,6 @@ services:
volumes: volumes:
- mysql:/var/lib/mysql/ - mysql:/var/lib/mysql/
redis: redis:
container_name: iot-redis container_name: iot-redis
image: redis:6-alpine image: redis:6-alpine
@ -27,46 +26,35 @@ services:
server: server:
container_name: iot-server container_name: iot-server
build: build:
context: ./ context: .
image: iot-server image: iot-server
restart: unless-stopped restart: unless-stopped
ports: ports:
- "8086:8086" - "8089:8086"
- "8088:8082"
environment: environment:
# https://github.com/polovyivan/docker-pass-configs-to-container # https://github.com/polovyivan/docker-pass-configs-to-container
SPRING_PROFILES_ACTIVE: local SPRING_PROFILES_ACTIVE: mysql
SPRING_DATASOURCE_DYNAMIC_DATASOURCE_MASTER_URL: ${MASTER_DATASOURCE_URL:-jdbc:mysql://iot-mysql:3306/iotkit?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true}
SPRING_DATASOURCE_DYNAMIC_DATASOURCE_MASTER_USERNAME: ${MASTER_DATASOURCE_USERNAME:-root}
SPRING_DATASOURCE_DYNAMIC_DATASOURCE_MASTER_PASSWORD: ${MASTER_DATASOURCE_PASSWORD:-123456}
# SPRING_DATASOURCE_DYNAMIC_DATASOURCE_SLAVE_URL: ${SLAVE_DATASOURCE_URL:-jdbc:mysql://iot-mysql:3306/iotkit?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true}
# SPRING_DATASOURCE_DYNAMIC_DATASOURCE_SLAVE_USERNAME: ${SLAVE_DATASOURCE_USERNAME:-root}
# SPRING_DATASOURCE_DYNAMIC_DATASOURCE_SLAVE_PASSWORD: ${SLAVE_DATASOURCE_PASSWORD:-123456}
SPRING_REDIS_HOST: ${REDIS_HOST:-iot-redis}
SPRING_REDIS_PORT: 6379
JAVA_OPTS: JAVA_OPTS:
${JAVA_OPTS:- ${JAVA_OPTS:-
-Xms512m -Xms512m
-Xmx512m -Xmx512m
-Djava.security.egd=file:/dev/./urandom -Djava.security.egd=file:/dev/./urandom
-DdisabledEmbeddedRedis=true
} }
ARGS: volumes:
--spring.datasource.dynamic.datasource.master.url=${MASTER_DATASOURCE_URL:-jdbc:mysql://iot-mysql:3306/iotkit?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true} - ./data/dist:/usr/share/nginx/html
--spring.datasource.dynamic.datasource.master.username=${MASTER_DATASOURCE_USERNAME:-root}
--spring.datasource.dynamic.datasource.master.password=${MASTER_DATASOURCE_PASSWORD:-123456}
--spring.datasource.dynamic.datasource.slave.url=${SLAVE_DATASOURCE_URL:-jdbc:mysql://iot-mysql:3306/iotkit?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true}
--spring.datasource.dynamic.datasource.slave.username=${SLAVE_DATASOURCE_USERNAME:-root}
--spring.datasource.dynamic.datasource.slave.password=${SLAVE_DATASOURCE_PASSWORD:-123456}
--spring.redis.host=${REDIS_HOST:-iot-redis}
depends_on: depends_on:
- redis - redis
- mysql
admin:
container_name: iot-admin
build:
context: ./iot-ui-admin
args:
NODE_ENV:
ENV=${NODE_ENV:-production}
PUBLIC_PATH=${PUBLIC_PATH:-/}
VUE_APP_TITLE=${VUE_APP_TITLE:-openiita管理系统}
image: iot-admin
restart: unless-stopped
ports:
- "8080:80"
depends_on:
- server
volumes: volumes:
mysql: mysql:

View File

@ -3,7 +3,7 @@ MYSQL_DATABASE=iotkit
MYSQL_ROOT_PASSWORD=123456 MYSQL_ROOT_PASSWORD=123456
## server ## server
JAVA_OPTS=-Xms512m -Xmx512m -Djava.security.egd=file:/dev/./urandom JAVA_OPTS=-Xms512m -Xmx512m -Djava.security.egd=file:/dev/./urandom -DdisabledEmbeddedRedis=true
MASTER_DATASOURCE_URL=jdbc:mysql://iot-mysql:3306/${MYSQL_DATABASE}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true MASTER_DATASOURCE_URL=jdbc:mysql://iot-mysql:3306/${MYSQL_DATABASE}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
MASTER_DATASOURCE_USERNAME=root MASTER_DATASOURCE_USERNAME=root