优化 Docker 部署

v1.4.1
hiparker 4 years ago
parent 7a049134bc
commit 8a69698108

@ -2,39 +2,39 @@
FROM openjdk:8u222-jre
MAINTAINER opsli.com
LABEL version=v1.3.3
LABEL version=V1.3.3
LABEL description=OPSLI-快速开发平台
LABEL qqGroup=724850675
# 工作目录
WORKDIR /usr/local/opsli/opsli-boot
# 设置环境常量
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
# 暴露端口
EXPOSE 7000
# 工作目录
WORKDIR ${WORKSPACE}
# 日志输出
RUN ["echo","OPSLI 快速开发平台正在 building..."]
RUN ["echo","OPSLI 快速开发平台 building..."]
# 创建日志目录
RUN mkdir -p /var/log
RUN mkdir -p ${LOG_PATH}
# 创建文件上传目录
RUN mkdir -p /upload/files
# 更改文件名称
RUN find ./opsli-starter/target -type f -regex ".*\.\(jar\)" | xargs -i mv {} ./opsli-starter/target/opsli-starter.jar
RUN mkdir -p ${UPLOAD_PATH}
# 拷贝Jar
ADD ./opsli-starter/target/opsli-starter.jar ./
# JVM configs deprecated for removal in opsli
ENV JVM_OPTS=" -Xmx2048m -Xms2048m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 " \
TZ=Asia/Shanghai \
ADD ./think-modules/target/${JAR_NAME} ./
# 切换为上海时区
RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone
ENTRYPOINT java ${JVM_OPTS} -Dfile.encoding=utf-8 -Djava.security.egd=file:/dev/./urandom -jar opsli-starter.jar
# 启动镜像
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"]
# 暴露端口
EXPOSE 8080

@ -0,0 +1,14 @@
FROM mysql:8.0.19
MAINTAINER opsli.com
LABEL version=V1.3.3
LABEL description=OPSLI-快速开发平台
LABEL qqGroup=724850675
ENV TZ=Asia/Shanghai
# 切换为上海时区
RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone
COPY ./opsli-boot.sql /docker-entrypoint-initdb.d

@ -0,0 +1,51 @@
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
ports:
- "8080:8080"
Loading…
Cancel
Save