🎨 docker自动集成

pull/41/head
ruibaby 2018-10-18 20:24:51 +08:00
parent 1167bceb6c
commit 2d2274a4ea
3 changed files with 147 additions and 16 deletions

View File

@ -4,9 +4,9 @@ LABEL maintainer="Ryan Wang<i@ryanc.cc>"
WORKDIR /opt/halo
ADD . /tmp
RUN cd /tmp && mvn package -Pprod && mv target/dist/halo/* /opt/halo/ \
RUN cd /tmp && mvn package -Pci && mv target/dist/halo/* /opt/halo/ \
&& rm -rf /tmp/* && rm -rf ~/.m2
EXPOSE 8090
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/opt/halo/app.jar"]
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/opt/halo/halo-latest.jar","--spring.profiles.active=docker"]

101
pom.xml
View File

@ -172,24 +172,22 @@
</dependencies>
<repositories>
<repository>
<id>aliyun</id>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>aliyun</id>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</pluginRepository>
</pluginRepositories>
<profiles>
<!-- 生产环境打包配置 -->
<profile>
<id>prod</id>
<repositories>
<repository>
<id>aliyun</id>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>aliyun</id>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</pluginRepository>
</pluginRepositories>
<build>
<finalName>halo</finalName>
<resources>
@ -262,6 +260,81 @@
</build>
</profile>
<!--CI环境-->
<profile>
<id>ci</id>
<build>
<finalName>halo</finalName>
<resources>
<resource>
<directory>src/main/java</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<!-- 跳过单元测试不然打包的时候会因为加载不了application.yaml报错 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
<outputDirectory>${project.build.directory}/dist/</outputDirectory>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 打包成jar文件并指定lib文件夹以及resources资源文件夹 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<mainClass>cc.ryanc.halo.Application</mainClass>
<classpathPrefix>lib/</classpathPrefix>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Class-Path>resources/</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- 开发环境 -->
<profile>
<id>dev</id>

View File

@ -0,0 +1,58 @@
server:
port: 8090
use-forward-headers: true
undertow:
io-threads: 2
worker-threads: 36
buffer-size: 1024
directBuffers: true
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
# H2database 配置
driver-class-name: org.h2.Driver
url: jdbc:h2:file:~/halo/halo
username: admin
password: 123456
#MySql配置
# driver-class-name: com.mysql.jdbc.Driver
# url: jdbc:mysql://127.0.0.1:3306/halodb?characterEncoding=utf8&useSSL=false
# username: root
# password: 123456
h2:
console:
settings:
web-allow-others: false
path: /h2-console
enabled: true
jpa:
hibernate:
ddl-auto: update
show-sql: false
freemarker:
allow-request-override: false
cache: false
check-template-location: true
charset: utf-8
content-type: text/html
expose-request-attributes: false
expose-session-attributes: false
expose-spring-macro-helpers: true
suffix: .ftl
settings:
auto_import: /spring.ftl as spring
servlet:
multipart:
max-file-size: 10MB
max-request-size: 10MB
# 多语言资源文件路径
messages:
basename: i18n/messages
logging:
file: ./logs/log.log