标签:etc wsize eid space node exe div package shell
本文基于ubuntu 16
1.安装openjdk8(略)
2.创建Dockerfile文件
cd ~
vi Dockerfile
Dockerfile内容
FROM openjdk:8
MAINTAINER Lee <li_xyu@foxmail.com>
WORKDIR /home
VOLUME /home/logs
ENV java_opts ‘-XX:+PrintGCDetails -XX:+PrintGCTimeStamps‘
#ADD package/pinpoint-agent /pinpoint-agent
ADD package/lee-spring-demo/target/lee-spring-demo.jar /home/
RUN chmod -x lee-spring-demo.jar \
&& /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo ‘Asia/Shanghai‘ >/etc/timezone
CMD java -jar $java_opts /home/lee-spring-demo.jar
EXPOSE 8080
EXPOSE 4100
3.编写启动shell脚本
#!/bin/sh NEW_PACK=`date +%Y%m%d%H%M%S` sudo docker build -t lee/demo:${NEW_PACK} /home/admin sudo docker stop $(sudo docker ps -a |grep l-4002|awk ‘{print $1}‘) sudo docker rm -f $(sudo docker ps -a |grep demo-4002|awk ‘{print $1}‘) sudo docker run -d --privileged=true -p 4002:8080 -p 4102:4100 -v /data/demo/logs:/home/logs -v /etc/localtime:/etc/localtime:ro -e java_opts="-Xms512M -Xmx1024M -XX:NewSize=256M -XX:MaxNewSize=512M -XX:MetaspaceSize=128M -XX:MaxMetaspaceSize=256M -Dpinpoint.agentId=13-21-4002 -Dpinpoint.applicationName=13-21-4002 -Dspring.profiles.active=uat -Dspring.nodeId=2" --name demo-4002 lee/demo:${NEW_PACK}
附:springboot直接部署到linux shell脚本
#!/bin/sh NEW_PACK=`date +%Y%m%d%H%M%S` cd /data/project/lee cp /home/admin/package/lee-spring-demo/target/lee-spring-demo.jar bolt-loan-api.${NEW_PACK}.jar kill -9 $(ps -ef |grep lee |grep -w ‘4001‘|awk ‘{print $2}‘) nohup java -jar -Xms512M -Xmx512M -XX:NewSize=256M -XX:MaxNewSize=256M -XX:MetaspaceSize=128M -XX:MaxMetaspaceSize=256M -Dspring.profiles.active=uat -Dspring.nodeId=1 -Dserver.port=4001 -Dxxl.job.executor.port=4101 bolt-loan-api.${NEW_PACK}.jar >/dev/null 2>&1 &
标签:etc wsize eid space node exe div package shell
原文地址:https://www.cnblogs.com/lixyu/p/11122880.html