feat: add docker file. close #206 (#545)

* feat: add docker file. close #206

* feat: dockerfile add license
pull/550/head
BigXin0109 2 years ago committed by GitHub
parent e26b798f67
commit 0fc7c2f998
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,36 @@
### Hippo4J Server Docker镜像构建
可以通过以下命令快速构建Hippo4J Server
方式一:
```
//进入到hippo4j-server工程路径下
mvn clean package
//默认打包是打包的tag是latest
docker build -t hippo4j-server ../hippo4j-server
```
方式二:
通过maven docker plugin
```
//进入到hippo4j-server工程路径下
mvn clean package -DskipTests docker:build
```
#### Docker 镜像方式搭建Hippo4J Server
- 下载镜像
```
// Docker地址https://hub.docker.com/r/xxxx/hippo4j-server/ (建议指定版本号)
docker pull hippo4j-server
```
- 创建容器并运行
```
docker run -p 6691:6691 --name hippo4j-server -d hippo4j-server:{指定版本}
/**
* 如需自定义 mysql 等配置,可通过 "-e PARAMS" 指定,参数格式 PARAMS="--key=value --key2=value2"
* 配置项参考文件:/hippo4j-server/src/main/resources/application.properties
* 如需自定义 JVM内存参数 等配置,可通过 "-e JAVA_OPTS" 指定,参数格式 JAVA_OPTS="-Xmx512m"
*/
docker run -e PARAMS="--spring.datasource.url=jdbc:mysql://localhost:3306/hippo4j_manager?characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8" -p 6691:6691 --name hippo4j-server -d hippo4j-server:{指定版本}
```

@ -0,0 +1,30 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM openjdk:8-jre-slim
MAINTAINER lijianxin
ENV PARAMS=""
ENV TZ=PRC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ADD conf/hippo4j-logback.xml /opt/hippo4j/logback.xml
ADD target/hippo4j-server.jar /opt/hippo4j/hippo4j-server.jar
WORKDIR /opt/hippo4j
ENTRYPOINT ["sh","-c","java -jar -Dhippo4j.home=/opt/hippo4j $JAVA_OPTS /opt/hippo4j/hippo4j-server.jar --server.tomcat.basedir=/opt/tomcat --logging.config=/opt/hippo4j/logback.xml $PARAMS"]

@ -87,6 +87,23 @@
</execution>
</executions>
</plugin>
<!-- docker -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.2</version>
<configuration>
<imageName>${project.artifactId}:${project.version}</imageName>
<dockerDirectory>${project.basedir}</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
</project>

Loading…
Cancel
Save