Skip to content

Commit

Permalink
feat(scaffold): provide run.sh & entrypoint.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
taccisum committed Jul 25, 2019
1 parent fb82a20 commit 58594b7
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
6 changes: 6 additions & 0 deletions generators/app/templates/.tmpl.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ FROM openjdk:8
WORKDIR /home

COPY ./target/app.jar /home

ADD entrypoint.sh /

RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
2 changes: 2 additions & 0 deletions generators/app/templates/README.tmpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ $ sh start-code.sh [-bl] [-p port]
- -l: 是否在启动后输出容器日志
- -p: 指定容器映射端口号

如果需要自定义启动命令,可以自行修改[`run.sh`](./run.sh)

## 开发参考

## Release Notes
Expand Down
3 changes: 3 additions & 0 deletions generators/app/templates/entrypoint.tmpl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

java -jar app.jar $@
10 changes: 10 additions & 0 deletions generators/app/templates/run.tmpl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

docker run \
--name $CONTAINER_NAME \
--restart=on-failure:5 \
--privileged \
-p $PORT:8080 \
-v $PWD/logs:/home/logs \
-d $IMG_NAME \
java -jar app.jar
12 changes: 4 additions & 8 deletions generators/app/templates/start-code.tmpl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,10 @@ info '删除已存在的容器' && docker rm -f $container_name

info '准备启动docker容器'

docker run \
--name $container_name \
--restart=on-failure:5 \
--privileged \
-p $port:8080 \
-v $PWD/logs:/home/logs \
-d $img_output \
java -jar app.jar
CONTAINER_NAME=$container_name \
PORT=$port \
IMG_NAME=$img_output \
./run.sh

if [ $? -eq 0 ];then
success '容器启动成功'
Expand Down

0 comments on commit 58594b7

Please sign in to comment.