mirror of
https://gitee.com/kennylee/docker.git
synced 2024-12-01 19:38:30 +08:00
优化springboot的docker化容器
This commit is contained in:
parent
e8af7e0e17
commit
dfa8162213
8
springboot/Dockerfile
Executable file
8
springboot/Dockerfile
Executable file
@ -0,0 +1,8 @@
|
||||
FROM registry.cn-hangzhou.aliyuncs.com/kennylee/java:openjdk-8-jre
|
||||
|
||||
MAINTAINER kennylee26 <kennylee26@gmail.com>
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
ENTRYPOINT "/entrypoint.sh"
|
@ -1,11 +1,11 @@
|
||||
# SpringBoot
|
||||
|
||||
运行SpringBoot的jar项目的Docker容器。
|
||||
运行SpringBoot的jar项目的Docker容器(JRE8)。
|
||||
|
||||
使用方法:
|
||||
|
||||
1. 把jar的部署包放到app目录下,并且命名为app.jar(即app/app.jar)
|
||||
2. 然后 docker-compose up -d 即可
|
||||
3. 如果有jar包更新,可替换掉app/app.jar包,然后docker-compose命令重新启动即可。
|
||||
1. 把使用编译好的springboot的jar部署包放到app目录下即可。(不要出现多个jar的情况,否则不保证得到你想要的运行结果,因为会默认执行其中一个。)
|
||||
2. 运行命令 `docker-compose up -d`
|
||||
3. 为了方便修改配置,默认在 `docker-compose.yml` 下配置了加载宿主机器中的 `application.yml`。如果不是你想要的,请自行修改。
|
||||
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -1,14 +1,11 @@
|
||||
version: '2'
|
||||
services:
|
||||
app:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/kennylee/java:openjdk-8-jre
|
||||
build: .
|
||||
volumes:
|
||||
- ./app/app.jar:/data/app.jar
|
||||
- ./app/:/data/app/
|
||||
- ./config/application.yml:/data/application.yml:ro
|
||||
ports:
|
||||
- "8080:8080"
|
||||
entrypoint:
|
||||
- java
|
||||
- -jar
|
||||
- /data/app.jar
|
||||
command:
|
||||
- --spring.config.location=/data/application.yml
|
||||
|
17
springboot/entrypoint.sh
Normal file
17
springboot/entrypoint.sh
Normal file
@ -0,0 +1,17 @@
|
||||
#! /bin/bash
|
||||
|
||||
BASE_PATH=/data/app/
|
||||
ORI_APP_FILE=$(find $BASE_PATH -type f -name "*.jar" 2>/dev/null | head -1)
|
||||
APP_FILE=${BASE_PATH}app.jar
|
||||
|
||||
if [ ${#ORI_APP_FILE} -gt 0 ]; then
|
||||
echo "create symbolic link for $ORI_APP_FILE"
|
||||
if [ -f $APP_FILE ]; then
|
||||
#echo "$APP_FILE was existed, remove that."
|
||||
rm $APP_FILE
|
||||
fi
|
||||
ln -s $ORI_APP_FILE $APP_FILE
|
||||
fi
|
||||
|
||||
# if $APP_FILE not exist, let it throw error。
|
||||
java -jar $APP_FILE "$@"
|
Loading…
Reference in New Issue
Block a user