Docker部署优化

v1.4.1
hiparker 4 years ago
parent d02bda950f
commit 4909e6eda4

@ -7,34 +7,24 @@ LABEL description=OPSLI-快速开发平台
LABEL qqGroup=724850675
# 设置环境常量
ENV WORKSPACE=/usr/local/opsli/opsli-boot \
LOG_PATH=/var/log \
UPLOAD_PATH=/upload/files \
TZ=Asia/Shanghai \
JAR_NAME=opsli-starter-1.3.3.jar
ENV TZ=Asia/Shanghai
# 工作目录
WORKDIR ${WORKSPACE}
WORKDIR /usr/local/opsli/opsli-boot
# 日志输出
RUN ["echo","OPSLI 快速开发平台 building..."]
# 创建日志目录
RUN mkdir -p ${LOG_PATH}
# 创建文件上传目录
RUN mkdir -p ${UPLOAD_PATH}
# 拷贝Jar
ADD ./think-modules/target/${JAR_NAME} ./
ADD ./think-modules/target/*.jar ./
# 切换为上海时区
RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone
# 启动镜像
ENTRYPOINT java -jar ${JAR_NAME} -Dfile.encoding=utf-8 -Djava.security.egd=file:/dev/./urandom --spring.profiles.active=docker --log.path=${LOG_PATH} --opsli.web.upload-path=${UPLOAD_PATH}
CMD ["-Xmx2048m -Xms2048m -XX:+UseG1GC -XX:MaxGCPauseMillis=200"]
ENTRYPOINT ["java", "-Dfile.encoding=utf-8", "-Djava.security.egd=file:/dev/./urandom", "-jar", "opsli-starter-1.3.3.jar"]
CMD ["-Xmx2048m", "-Xms2048m", "-XX:+UseG1GC", "-XX:MaxGCPauseMillis=200", "--spring.profiles.active=dev"]
# 暴露端口
EXPOSE 8080
EXPOSE 8080

@ -0,0 +1,57 @@
version: '3.3'
services:
# 构建 MySQL数据库 这里不指定数据库文件 防止误操作 等隐患问题
opsli-boot-mysql:
build: ./db-file
image: opsli-boot-mysql
restart: always
environment:
# root 账户默认密码 生产时请更改
MYSQL_ROOT_PASSWORD: 123456
MYSQL_ROOT_HOST: '%'
TZ: Asia/Shanghai
LANG: en_US.UTF-8
container_name: opsli-boot-mysql
command:
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
--lower_case_table_names=1
--max_allowed_packet=128M
--default-authentication-plugin=caching_sha2_password
volumes:
- /var/mysql/data:/var/lib/mysql #挂载 MySQL数据
ports:
- "3306:3306"
# 构建 Redis
opsli-boot-redis:
image: redis:6.2.3
restart: always
container_name: opsli-boot-redis
environment:
TZ: Asia/Shanghai
LANG: en_US.UTF-8
command: redis-server /usr/local/etc/redis/redis.conf --appendonly yes # 表示通过挂载配置文件追加配置
volumes:
- /var/redis/data:/data #挂载 Redis数据
- /var/redis/conf/redis.conf:/usr/local/etc/redis/redis.conf #挂载 Redis配置
ports:
- "6379:6379"
opsli-boot:
build: ./
restart: on-failure
container_name: opsli-boot
image: opsli-boot
environment:
TZ: Asia/Shanghai
LANG: en_US.UTF-8
command:
- -Xmx2048m
- -Xms2048m
- -XX:+UseG1GC
- -XX:MaxGCPauseMillis=200
- --spring.profiles.active=dev
ports:
- "8080:8080"

@ -1,54 +1,18 @@
version: '3.3'
services:
# 构建 MySQL数据库 这里不指定数据库文件 防止误操作 等隐患问题
opsli-boot-mysql:
build: ./db-file
image: opsli-boot-mysql
restart: always
environment:
# root 账户默认密码 生产时请更改
MYSQL_ROOT_PASSWORD: 123456
MYSQL_ROOT_HOST: '%'
TZ: Asia/Shanghai
LANG: en_US.UTF-8
container_name: opsli-boot-mysql
command:
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
--lower_case_table_names=1
--max_allowed_packet=128M
--default-authentication-plugin=caching_sha2_password
volumes:
- /var/mysql/data:/var/lib/mysql #挂载 MySQL数据
ports:
- "3306:3306"
# 构建 Redis
opsli-boot-redis:
image: redis:6.2.3
restart: always
container_name: opsli-boot-redis
environment:
TZ: Asia/Shanghai
LANG: en_US.UTF-8
command: redis-server /usr/local/etc/redis/redis.conf --appendonly yes # 表示通过挂载配置文件追加配置
volumes:
- /var/redis/data:/data #挂载 Redis数据
- /var/redis/conf/redis.conf:/usr/local/etc/redis/redis.conf #挂载 Redis配置
ports:
- "6379:6379"
opsli-boot:
build: ./
restart: on-failure
depends_on:
- opsli-boot-mysql
- opsli-boot-redis
container_name: opsli-boot
image: opsli-boot
environment:
TZ: Asia/Shanghai
LANG: en_US.UTF-8
command:
- -Xmx2048m
- -Xms2048m
- -XX:+UseG1GC
- -XX:MaxGCPauseMillis=200
- --spring.profiles.active=dev
ports:
- "8080:8080"

@ -1,82 +0,0 @@
## ---- 测试环境 ---- ##
# 端口设置
server:
port: 8080
spring:
#redis 配置
redis:
database: 0
host: opsli-boot-redis
password: '123456'
port: 6379
# 数据库配置
datasource:
# 数据库连接池监控
druid:
stat-view-servlet:
# 数据库监控开关
enabled: true
# 登录用户名/密码
login-username: admin
login-password: 123456
# IP 白名单,没有配置或者为空,则允许所有访问
allow:
# IP 黑名单,若白名单也存在,则优先使用
deny:
# 多数据源
dynamic:
#主数据源
#设置默认的数据源或者数据源组,默认值即为master,如果你主从默认下主库的名称就是master可不定义此项。
#primary: master
datasource:
master:
url: jdbc:mysql://opsli-boot-mysql:3306/opsli-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai
username: root
password: MYSQL0p9o8i7u
driver-class-name: com.mysql.cj.jdbc.Driver
# 多数据源配置
#slave-datasource:
#url: jdbc:mysql://127.0.0.1:3306/opsli-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai
#username: root
#password: 12345678
#driver-class-name: com.mysql.cj.jdbc.Driver
# Redisson 分布式锁
redisson:
lock:
server:
enable: true
type: standalone
address: "${spring.redis.host}:${spring.redis.port}"
password: "${spring.redis.password}"
database: ${spring.redis.database}
# knife4j 文档 配置
knife4j:
basic:
## 开启Swagger的Basic认证功能,默认是false
enable: false
## Basic认证用户名
username: admin
## Basic认证密码
password: 123456
# 是否生产环境 (生产环境默认屏蔽文档)
production: false
# opsli 自定义配置
opsli:
# 演示模式
enable-demo: true
# web 上传文件路径
web:
upload-path: /upload/files
# 系统日志
log:
path: /var/log
Loading…
Cancel
Save