add: docker相关配置

V0.5.x
jay 2023-09-07 19:13:39 +08:00
parent 90298599ac
commit a1c84249e5
2 changed files with 94 additions and 0 deletions

75
docker-compose.yml Normal file
View File

@ -0,0 +1,75 @@
version: "3.4"
services:
mysql:
container_name: iot-mysql
image: mysql:8
restart: unless-stopped
tty: true
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: ${MYSQL_DATABASE:-iotkit}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-123456}
volumes:
- mysql:/var/lib/mysql/
redis:
container_name: iot-redis
image: redis:6-alpine
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- redis:/data
server:
container_name: iot-server
build:
context: ./
image: iot-server
restart: unless-stopped
ports:
- "8086:8086"
environment:
# https://github.com/polovyivan/docker-pass-configs-to-container
SPRING_PROFILES_ACTIVE: local
JAVA_OPTS:
${JAVA_OPTS:-
-Xms512m
-Xmx512m
-Djava.security.egd=file:/dev/./urandom
}
ARGS:
--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}
depends_on:
- redis
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:
mysql:
driver: local
redis:
driver: local

19
docker.env Normal file
View File

@ -0,0 +1,19 @@
## mysql
MYSQL_DATABASE=iotkit
MYSQL_ROOT_PASSWORD=123456
## server
JAVA_OPTS=-Xms512m -Xmx512m -Djava.security.egd=file:/dev/./urandom
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_PASSWORD=${MYSQL_ROOT_PASSWORD}
SLAVE_DATASOURCE_URL=${MASTER_DATASOURCE_URL}
SLAVE_DATASOURCE_USERNAME=${MASTER_DATASOURCE_USERNAME}
SLAVE_DATASOURCE_PASSWORD=${MASTER_DATASOURCE_PASSWORD}
REDIS_HOST=iot-redis
## admin
NODE_ENV=production
PUBLIC_PATH=/
VUE_APP_TITLE=iot管理系统