提交 1d80109c 编写于 作者: 智布道's avatar 智布道 👁

dockerfile & docker-compose

上级 0b3614e1
# 环境版本
FROM anapsix/alpine-java:8_server-jre_unlimited
MAINTAINER yadong.zhang0415@gmail.com
# JVM调优参数等额外参数
ENV PARAMS ""
ENV TZ=PRC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# 指定容器端口
EXPOSE 8085
# 添加本地 JAR 到容器内
ADD target/blog-admin.jar app.jar
# 容器启动后执行的命令
ENTRYPOINT ["java", "-jar","app.jar" , "-Djava.security.egd=file:/dev/./urandom","$PARAMS"]
......@@ -19,6 +19,24 @@
<dependency>
<groupId>com.zyd</groupId>
<artifactId>blog-core</artifactId>
<exclusions>
<exclusion>
<artifactId>lombok</artifactId>
<groupId>org.projectlombok</groupId>
</exclusion>
<exclusion>
<artifactId>mybatis-spring-boot-starter</artifactId>
<groupId>org.mybatis.spring.boot</groupId>
</exclusion>
<exclusion>
<artifactId>log4j</artifactId>
<groupId>log4j</groupId>
</exclusion>
<exclusion>
<artifactId>kotlin-stdlib-common</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
......
# Server settings
server:
tomcat:
basedir: /var/tmp/website-blog-admin
basedir: /var/tmp/oneblog/blog-admin
# SPRING PROFILES
spring:
profiles:
include: [center-dev]
# 指定默认MimeMessage的编码,默认为: UTF-8
mail:
default-encoding: UTF-8
# 指定SMTP server使用的协议,默认为: smtp
protocol: smtp
# 指定SMTP server host.
host: xxx
port: 465
# 指定SMTP server的用户名.
username: xxx
# 指定SMTP server登录密码:
password: xxx
# 指定是否在启动时测试邮件服务器连接,默认为false
test-connection: false
properties:
mail.smtp.auth: true
# 腾讯企业邮箱 下两个配置必须!!!
mail.smtp.ssl.enable: true
mail.smtp.socketFactory.class: javax.net.ssl.SSLSocketFactory
mail.smtp.socketFactory.port: 465
mail.smtp.starttls.enable: true
mail.smtp.starttls.required: true
mail.smtp.connectiontimeout: 50000
mail.smtp.timeout: 30000
mail.smtp.writetimeout: 50000
# Redis数据库索引(默认为0)
redis:
jedis:
pool:
# 连接池最大连接数(使用负值表示没有限制)
max-active: 8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
# 连接池中的最大空闲连接
max-idle: 8
# 连接池中的最小空闲连接
min-idle: 0
# 连接超时时间(毫秒)
timeout: 5000ms
# 默认的数据过期时间,主要用于shiro权限管理
expire: 2592000
# logging settings
logging:
path: /var/tmp/website-blog-admin
config: classpath:logback-spring.xml
path: /var/tmp/oneblog/blog-admin
####################################自定义配置##########################################
app:
# 是否启用kaptcha验证码
enableKaptcha: false
enableKaptcha: ${ONEBLOG_APP_ENABLE_KAPTCHA:false}
# 启用后,项目在启动时会打印数据库(Mysql和Redis)链接信息(包含密码)
# 代码请参考
enabledConfigLog: true
enabledConfigLog: ${ONEBLOG_APP_ENABLE_CONFIGLOG:false}
# shiro配置项
shiro:
loginUrl: "/passport/login/"
......
# Server settings
server:
tomcat:
basedir: /var/tmp/website-blog-admin
# SPRING PROFILES
spring:
profiles:
include: [center-test]
# 指定默认MimeMessage的编码,默认为: UTF-8
mail:
default-encoding: UTF-8
# 指定SMTP server使用的协议,默认为: smtp
protocol: smtp
# 指定SMTP server host.
host: xxx
port: 465
# 指定SMTP server的用户名.
username: xxx
# 指定SMTP server登录密码:
password: xxx
# 指定是否在启动时测试邮件服务器连接,默认为false
test-connection: false
properties:
mail.smtp.auth: true
# 腾讯企业邮箱 下两个配置必须!!!
mail.smtp.ssl.enable: true
mail.smtp.socketFactory.class: javax.net.ssl.SSLSocketFactory
mail.smtp.socketFactory.port: 465
mail.smtp.starttls.enable: true
mail.smtp.starttls.required: true
mail.smtp.connectiontimeout: 50000
mail.smtp.timeout: 30000
mail.smtp.writetimeout: 50000
# Redis数据库索引(默认为0)
redis:
jedis:
pool:
# 连接池最大连接数(使用负值表示没有限制)
max-active: 8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
# 连接池中的最大空闲连接
max-idle: 8
# 连接池中的最小空闲连接
min-idle: 0
# 连接超时时间(毫秒)
timeout: 5000ms
# 默认的数据过期时间,主要用于shiro权限管理
expire: 2592000
# logging settings
logging:
path: /var/tmp/website-blog-admin
####################################自定义配置##########################################
app:
# 是否启用kaptcha验证码
enableKaptcha: false
# 启用后,项目在启动时会打印数据库(Mysql和Redis)链接信息(包含密码)
# 代码请参考
enabledConfigLog: false
# shiro配置项
shiro:
loginUrl: "/passport/login/"
successUrl: "/"
unauthorizedUrl: "/error/403"
####################################自定义配置##########################################
......@@ -26,15 +26,12 @@
</layout>
</appender>
<logger name="org.springframework.core.env" level="ERROR"/>
<logger name="us.codecraft.webmagic.downloader" level="WARN"/>
<logger name="com.zyd.blog.framework.runner" level="INFO"/>
<logger name="org.springframework.core.env" level="DEBUG"/>
<logger name="us.codecraft.webmagic.downloader" level="DEBUG"/>
<logger name="com.zyd.blog.framework.runner" level="DEBUG"/>
<!-- 测试环境+开发环境,日志级别为INFO且不写日志文件 -->
<springProfile name="test,dev">
<logger name="com.zyd.blog" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>
<springProfile name="dev">
<root level="INFO">
<appender-ref ref="STDOUT"/>
</root>
......@@ -42,15 +39,10 @@
<!-- 生产环境. 日志级别为WARN且写日志文件-->
<springProfile name="prod">
<logger name="com.zyd.blog" additivity="false">
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE" />
</logger>
<root level="WARN">
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE" />
</root>
</springProfile>
</configuration>
\ No newline at end of file
</configuration>
package com.zyd.blog.util;
import cn.hutool.core.util.ReUtil;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletRequest;
......@@ -15,27 +16,56 @@ import javax.servlet.http.HttpServletRequest;
*/
public class IpUtil {
private static final String IPV4_IPV6_PATTERN = "([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})|(((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:)))(%.+)?)";
/**
* 获取真实IP
* 获取当前请求者的ip
*
* @param request
* @return
* @return {String}
*/
public static String getRealIp(HttpServletRequest request) {
String ip = request.getHeader("x-forwarded-for");
return checkIp(ip) ? ip : (
checkIp(ip = request.getHeader("Proxy-Client-IP")) ? ip : (
checkIp(ip = request.getHeader("WL-Proxy-Client-IP")) ? ip :
request.getRemoteAddr()));
if (null == request) {
return "";
}
String[] headers = {"X-Forwarded-For", "X-Real-IP", "Proxy-Client-IP", "WL-Proxy-Client-IP", "HTTP_CLIENT_IP", "HTTP_X_FORWARDED_FOR"};
String ip;
for (String header : headers) {
ip = request.getHeader(header);
if (isValidIp(ip)) {
return getMultistageReverseProxyIp(ip);
}
}
ip = request.getRemoteAddr();
return getMultistageReverseProxyIp(ip);
}
/**
* 从多级反向代理中获得第一个非unknown IP地址
*
* @param ip 获得的IP地址
* @return 第一个非unknown IP地址
*/
private static String getMultistageReverseProxyIp(String ip) {
// 多级反向代理检测
if (ip != null && ip.indexOf(",") > 0) {
final String[] ips = ip.trim().split(",");
for (String subIp : ips) {
if (isValidIp(subIp)) {
ip = subIp;
break;
}
}
}
return ReUtil.getGroup0(IPV4_IPV6_PATTERN, ip);
}
/**
* 校验IP
*
* @param ip
* @return
* @param ip 获得的IP地址
* @return 是否为未知的ip
*/
private static boolean checkIp(String ip) {
private static boolean isValidIp(String ip) {
return !StringUtils.isEmpty(ip) && !"unknown".equalsIgnoreCase(ip) && RegexUtils.isIp(ip);
}
......
......@@ -7,23 +7,20 @@ spring:
connection-init-sqls: set names utf8mb4
driver-class-name: com.mysql.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://localhost:3306/dblog?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: root
url: jdbc:mysql://${ONEBLOG_DATASOURCE_HOST:127.0.0.1}:${ONEBLOG_DATASOURCE_PORT:3306}/${ONEBLOG_DATASOURCE_DATABASE_NAME:dblog}?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&allowPublicKeyRetrieval=true
username: ${ONEBLOG_DATASOURCE_USERNAME:root}
password: ${ONEBLOG_DATASOURCE_PASSWORD:root}
####### Redis Config #######
redis:
database: 5
database: ${ONEBLOG_REDIS_DATABASE_INDEX:1}
# Redis服务器地址
host: 127.0.0.1
host: ${ONEBLOG_REDIS_HOST:127.0.0.1}
# Redis服务器连接端口
port: 6379
port: ${ONEBLOG_REDIS_PORT:6379}
# Redis服务器连接密码(默认为空)
password: qwe!@#123
password: ${ONEBLOG_REDIS_PASSWORD:123456ZHYD}
####### redis缓存服务配置 #######
session:
store-type: redis
####### 自定义配置 #######
####### 自定义配置 #######
spring:
profiles:
include: [center]
####### database Config #######
datasource:
druid:
connection-init-sqls: set names utf8mb4
driver-class-name: com.mysql.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://localhost:3306/dblog?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: root
####### Redis Config #######
redis:
database: 5
# Redis服务器地址
host: 127.0.0.1
# Redis服务器连接端口
port: 6379
# Redis服务器连接密码(默认为空)
password: qwe!@#123
####### redis缓存服务配置 #######
session:
store-type: redis
####### 自定义配置 #######
####### 自定义配置 #######
spring:
# 指定默认MimeMessage的编码,默认为: UTF-8
mail:
default-encoding: UTF-8
# 指定SMTP server使用的协议,默认为: smtp
protocol: smtp
# 指定SMTP server host.
host: ${ONEBLOG_MAIL_HOST}
port: ${ONEBLOG_MAIL_PORT:465}
# 指定SMTP server的用户名.
username: ${ONEBLOG_MAIL_USERNAME}
# 指定SMTP server登录密码:
password: ${ONEBLOG_MAIL_PASSWORD}
# 指定是否在启动时测试邮件服务器连接,默认为false
test-connection: false
properties:
mail.smtp.auth: true
# 腾讯企业邮箱 下两个配置必须!!!
mail.smtp.ssl.enable: true
mail.smtp.socketFactory.class: javax.net.ssl.SSLSocketFactory
mail.smtp.socketFactory.port: 465
mail.smtp.starttls.enable: true
mail.smtp.starttls.required: true
mail.smtp.connectiontimeout: 50000
mail.smtp.timeout: 30000
mail.smtp.writetimeout: 50000
# Redis数据库索引(默认为0)
redis:
jedis:
pool:
# 连接池最大连接数(使用负值表示没有限制)
max-active: 8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
# 连接池中的最大空闲连接
max-idle: 8
# 连接池中的最小空闲连接
min-idle: 0
# 连接超时时间(毫秒)
timeout: 5000ms
# 默认的数据过期时间,主要用于shiro权限管理
expire: 2592000
# 环境版本
FROM anapsix/alpine-java:8_server-jre_unlimited
MAINTAINER yadong.zhang0415@gmail.com
# JVM调优参数等额外参数
ENV PARAMS ""
ENV TZ=PRC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# 指定容器端口
EXPOSE 8085
# 添加本地 JAR 到容器内
ADD target/blog-web.jar app.jar
# 容器启动后执行的命令
ENTRYPOINT ["java", "-jar","app.jar" , "-Djava.security.egd=file:/dev/./urandom","$PARAMS"]
# Server settings
server:
tomcat:
basedir: /var/tmp/website-blog-web
basedir: /var/tmp/oneblog/blog-web
# SPRING PROFILES
spring:
profiles:
include: [center-dev]
# 指定默认MimeMessage的编码,默认为: UTF-8
mail:
default-encoding: UTF-8
# 指定SMTP server使用的协议,默认为: smtp
protocol: smtp
# 指定SMTP server host.
host: xxx
port: 465
# 指定SMTP server的用户名.
username: xxx
# 指定SMTP server登录密码:
password: xxx
# 指定是否在启动时测试邮件服务器连接,默认为false
test-connection: false
properties:
mail.smtp.auth: true
# 腾讯企业邮箱 下两个配置必须!!!
mail.smtp.ssl.enable: true
mail.smtp.socketFactory.class: javax.net.ssl.SSLSocketFactory
mail.smtp.socketFactory.port: 465
mail.smtp.starttls.enable: true
mail.smtp.starttls.required: true
mail.smtp.connectiontimeout: 50000
mail.smtp.timeout: 30000
mail.smtp.writetimeout: 50000
# Redis数据库索引(默认为0)
redis:
jedis:
pool:
# 连接池最大连接数(使用负值表示没有限制)
max-active: 8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
# 连接池中的最大空闲连接
max-idle: 8
# 连接池中的最小空闲连接
min-idle: 0
# 连接超时时间(毫秒)
timeout: 5000ms
# 默认的数据过期时间,主要用于shiro权限管理
expire: 2592000
# logging settings
logging:
path: /var/tmp/website-blog-web
config: classpath:logback-spring.xml
path: /var/tmp/oneblog/blog-web
# braum过滤器,用于过滤恶意请求
braum:
......@@ -63,8 +23,8 @@ braum:
####################################自定义配置##########################################
app:
# 是否启用kaptcha验证码
enableKaptcha: false
enableKaptcha: ${ONEBLOG_APP_ENABLE_KAPTCHA:false}
# 启用后,项目在启动时会打印数据库(Mysql和Redis)链接信息(包含密码)
# 代码请参考
enabledConfigLog: true
enabledConfigLog: ${ONEBLOG_APP_ENABLE_CONFIGLOG:false}
####################################自定义配置##########################################
# Server settings
server:
tomcat:
basedir: /var/tmp/website-blog-web
# SPRING PROFILES
spring:
profiles:
include: [center-test]
active:
# 指定默认MimeMessage的编码,默认为: UTF-8
mail:
default-encoding: UTF-8
# 指定SMTP server使用的协议,默认为: smtp
protocol: smtp
# 指定SMTP server host.
host: xxx
port: 465
# 指定SMTP server的用户名.
username: xxx
# 指定SMTP server登录密码:
password: xxx
# 指定是否在启动时测试邮件服务器连接,默认为false
test-connection: false
properties:
mail.smtp.auth: true
# 腾讯企业邮箱 下两个配置必须!!!
mail.smtp.ssl.enable: true
mail.smtp.socketFactory.class: javax.net.ssl.SSLSocketFactory
mail.smtp.socketFactory.port: 465
mail.smtp.starttls.enable: true
mail.smtp.starttls.required: true
mail.smtp.connectiontimeout: 50000
mail.smtp.timeout: 30000
mail.smtp.writetimeout: 50000
# Redis数据库索引(默认为0)
redis:
jedis:
pool:
# 连接池最大连接数(使用负值表示没有限制)
max-active: 8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
# 连接池中的最大空闲连接
max-idle: 8
# 连接池中的最小空闲连接
min-idle: 0
# 连接超时时间(毫秒)
timeout: 5000ms
# 默认的数据过期时间,主要用于shiro权限管理
expire: 2592000
# logging settings
logging:
path: /var/tmp/website-blog-web
# braum过滤器,用于过滤恶意请求
braum:
limit:
access:
type: redis
threshold: 15
interval: 5000
####################################自定义配置##########################################
app:
# 是否启用kaptcha验证码
enableKaptcha: false
# 启用后,项目在启动时会打印数据库(Mysql和Redis)链接信息(包含密码)
# 代码请参考
enabledConfigLog: false
####################################自定义配置##########################################
......@@ -14,6 +14,9 @@
Date: 04/01/2019 15:45:01
*/
CREATE database if NOT EXISTS `dblog` default character set utf8mb4 collate utf8mb4_unicode_ci;
use `dblog`;
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
......
MYSQL_ROOT_HOST=%
# 默认的工作目录, 默认是 windows 盘符,如果运行到其他操作系统中时,注意修改该配置
ONEBLOG_APP_DIR=D://var/.oneblog
# redis 配置
ONEBLOG_REDIS_DATABASE_INDEX=1
ONEBLOG_REDIS_HOST=oneblog-redis
ONEBLOG_REDIS_PORT=6379
# 建议修改为复制密码
ONEBLOG_REDIS_PASSWORD=oneblog123456
# mysql 配置
ONEBLOG_DATASOURCE_HOST=oneblog-mysql
ONEBLOG_DATASOURCE_PORT=3306
ONEBLOG_DATASOURCE_DATABASE_NAME=dblog
ONEBLOG_DATASOURCE_USERNAME=root
# 建议修改为复制密码
ONEBLOG_DATASOURCE_PASSWORD=root
# email 配置
ONEBLOG_MAIL_HOST=
ONEBLOG_MAIL_PORT=465
ONEBLOG_MAIL_USERNAME=
ONEBLOG_MAIL_PASSWORD=
# oneblog 自定义配置
# 是否启用kaptcha验证码
ONEBLOG_APP_ENABLE_KAPTCHA=false
# 启用后,项目在启动时会打印数据库(Mysql和Redis)链接信息(包含密码)
ONEBLOG_APP_ENABLE_CONFIGLOG=true
version: '3.3'
services:
# MySQL
oneblog-mysql:
image: oneblog/mysql
build: ./mysql
environment:
MYSQL_ROOT_PASSWORD: ${ONEBLOG_DATASOURCE_PASSWORD}
TZ: Asia/Shanghai
restart: always
container_name: oneblog-mysql
hostname: oneblog-mysql
volumes:
- ${ONEBLOG_APP_DIR}/mysql:/var/lib/mysql
ports:
- 33066:3306
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
timeout: 20s
retries: 10
networks:
- oneblog
# Redis
oneblog-redis:
image: redis
restart: always
container_name: oneblog-redis
hostname: oneblog-redis
command: redis-server --appendonly yes --requirepass ${ONEBLOG_REDIS_PASSWORD} --bind oneblog-redis
ports:
- 63799:6379
volumes:
- ${ONEBLOG_APP_DIR}/redis/:/data/
healthcheck:
test: [ "CMD", "redis-cli" ]
timeout: 20s
retries: 10
networks:
- oneblog
# admin 服务
oneblog-admin:
image: oneblog/blog-admin
build: ../../blog-admin
restart: always
container_name: oneblog-admin
hostname: oneblog-admin
environment:
ONEBLOG_REDIS_DATABASE_INDEX:
ONEBLOG_REDIS_HOST:
ONEBLOG_REDIS_PORT:
ONEBLOG_REDIS_PASSWORD:
ONEBLOG_DATASOURCE_HOST:
ONEBLOG_DATASOURCE_PORT:
ONEBLOG_DATASOURCE_DATABASE_NAME:
ONEBLOG_DATASOURCE_USERNAME:
ONEBLOG_DATASOURCE_PASSWORD:
ONEBLOG_MAIL_HOST:
ONEBLOG_MAIL_PORT:
ONEBLOG_MAIL_USERNAME:
ONEBLOG_MAIL_PASSWORD:
ONEBLOG_APP_ENABLE_KAPTCHA:
ONEBLOG_APP_ENABLE_CONFIGLOG:
volumes:
- ${ONEBLOG_APP_DIR}:/var/tmp/oneblog
depends_on:
oneblog-redis:
condition: service_healthy
oneblog-mysql:
condition: service_healthy
links:
- oneblog-redis
- oneblog-mysql
ports:
- 8085:8085
networks:
- oneblog
# admin 服务
oneblog-web:
image: oneblog/blog-web
build: ../../blog-web
restart: always
container_name: oneblog-web
hostname: oneblog-web
environment:
ONEBLOG_REDIS_DATABASE_INDEX:
ONEBLOG_REDIS_HOST:
ONEBLOG_REDIS_PORT:
ONEBLOG_REDIS_PASSWORD:
ONEBLOG_DATASOURCE_HOST:
ONEBLOG_DATASOURCE_PORT:
ONEBLOG_DATASOURCE_DATABASE_NAME:
ONEBLOG_DATASOURCE_USERNAME:
ONEBLOG_DATASOURCE_PASSWORD:
ONEBLOG_MAIL_HOST:
ONEBLOG_MAIL_PORT:
ONEBLOG_MAIL_USERNAME:
ONEBLOG_MAIL_PASSWORD:
ONEBLOG_APP_ENABLE_KAPTCHA:
ONEBLOG_APP_ENABLE_CONFIGLOG:
volumes:
- ${ONEBLOG_APP_DIR}:/var/tmp/oneblog
depends_on:
oneblog-redis:
condition: service_healthy
oneblog-mysql:
condition: service_healthy
links:
- oneblog-redis
- oneblog-mysql
ports:
- 8443:8443
networks:
- oneblog
networks:
oneblog:
driver: bridge
# FROM mysql:8.0.20
FROM mysql:5.7
MAINTAINER yadong.zhang0415@gmail.com
ENV TZ=Asia/Shanghai
ADD ./config/mysqld.cnf /etc/mysql/mysql.conf.d/mysqld.cnf
RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
COPY ../../db/dblog.sql /docker-entrypoint-initdb.d
COPY ../../db/init_data.sql /docker-entrypoint-initdb.d
[client]
port=3306
default-character-set=utf8mb4
socket = /var/run/mysqld/mysqld.sock
[mysql]
no-auto-rehash
auto-rehash
default-character-set=utf8mb4
[mysqld]
user=mysql
pid-file=/var/run/mysqld/mysqld.pid
socket=/var/run/mysqld/mysqld.sock
datadir=/var/lib/mysql
default-storage-engine=INNODB
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
default-time-zone='+8:00'
innodb_rollback_on_timeout='ON'
max_connections=500
innodb_lock_wait_timeout=500
sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
transaction_isolation=READ-COMMITTED
auto_increment_offset = 1
connect_timeout = 20
wait_timeout=86400
interactive_timeout=86400
interactive_timeout = 7200
log_bin_trust_function_creators = 1
wait_timeout = 7200
sort_buffer_size = 32M
join_buffer_size = 128M
max_allowed_packet = 1024M
tmp_table_size = 2097152
explicit_defaults_for_timestamp = 1
read_buffer_size = 16M
read_rnd_buffer_size = 32M
query_cache_type = 1
query_cache_size = 2M
table_open_cache = 1500
table_definition_cache = 1000
thread_cache_size = 768
back_log = 3000
open_files_limit = 65536
skip-name-resolve
########log settings########
log-output=FILE
general_log = ON
general_log_file=/var/lib/mysql/general.log
slow_query_log = ON
slow_query_log_file=/var/lib/mysql/slowquery.log
long_query_time=10
#log-error=/var/lib/mysql/error.log
log_queries_not_using_indexes = OFF
log_throttle_queries_not_using_indexes = 0
#expire_logs_days = 120
min_examined_row_limit = 100
########innodb settings########
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_buffer_pool_size = 6144M
innodb_file_per_table = on
innodb_buffer_pool_instances = 20
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_log_file_size = 300M
innodb_log_files_in_group = 2
innodb_log_buffer_size = 16M
innodb_undo_logs = 128
#innodb_undo_tablespaces = 3
#innodb_undo_log_truncate = 1
#innodb_max_undo_log_size = 2G
innodb_flush_method = O_DIRECT
innodb_flush_neighbors = 1
innodb_purge_threads = 4
innodb_large_prefix = 1
innodb_thread_concurrency = 64
innodb_print_all_deadlocks = 1
innodb_strict_mode = 1
innodb_sort_buffer_size = 64M
innodb_flush_log_at_trx_commit=1
innodb_autoextend_increment=64
innodb_concurrency_tickets=5000
innodb_old_blocks_time=1000
innodb_open_files=65536
innodb_stats_on_metadata=0
innodb_file_per_table=1
innodb_checksum_algorithm=0
#innodb_data_file_path=ibdata1:60M;ibdata2:60M;autoextend:max:1G
innodb_data_file_path = ibdata1:12M:autoextend
#innodb_temp_data_file_path = ibtmp1:500M:autoextend:max:20G
#innodb_buffer_pool_dump_pct = 40
#innodb_page_cleaners = 4
#innodb_purge_rseg_truncate_frequency = 128
binlog_gtid_simple_recovery=1
#log_timestamps=system
##############
delayed_insert_limit = 100
delayed_insert_timeout = 300
delayed_queue_size = 1000
delay_key_write = ON
disconnect_on_expired_password = ON
div_precision_increment = 4
end_markers_in_json = OFF
eq_range_index_dive_limit = 10
innodb_adaptive_flushing = ON
innodb_adaptive_hash_index = ON
innodb_adaptive_max_sleep_delay = 150000
#innodb_additional_mem_pool_size = 2097152
innodb_autoextend_increment = 64
innodb_autoinc_lock_mode = 1
......@@ -116,17 +116,6 @@
</properties>
<build>
<!-- 产生的构件的文件名,默认值是${artifactId}-${version}-->
<finalName>${project.artifactId}-${project.version}</finalName>
</build>
</profile>
<!--测试配置-->
<profile>
<id>test</id>
<properties>
<profileActive>test</profileActive>
</properties>
<build>
<!-- 产生的构件的文件名-->
<finalName>${project.artifactId}</finalName>
</build>
</profile>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册