jenkins+docker部署项目

jenkins + maven + jdk + docker + docker register + dockerfile

jenkins插件

# 安装插件
SSH

# 配置

系统设置-> SSH remote hosts

Dockerfile

# Dockerfile
# 基于的镜像
#FROM openjdk:8-jdk-alpine
FROM openjdk:8u265

ADD target/chemical.jar chemical.jar
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
#RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
# -Djava.security.egd=file:/dev/./urandom 可解决tomcat可能启动慢的问题
# 具体可查看:https://www.cnblogs.com/mightyvincent/p/7685310.html
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/chemical.jar"]

# 对外端口
EXPOSE 10140

Build

clean package -Dmaven.test.skip=true

Post Steps


IMAGE_NAME="inner.meeno.net:5000/chemical:1.0"

# 进入项目
echo $PWD
cd /var/lib/jenkins/workspace/chemical_test/


# docker build
sudo docker build -t $IMAGE_NAME .

# push docker registry
sudo docker push $IMAGE_NAME

# success
echo 'push docker registry success'

服务集器上

    echo '{ "insecure-registries":["xxx.xxx.xxx.xxx:5000"] }' > /etc/docker/daemon.json
    systemctl restart docker

构建后操作

Post Steps -> Execute shell script on remote host using ssh

command:


docker pull inner.meeno.net:5000/chemical:1.0

docker rm -f chemical_server

docker run -d -p 10140:10140 --name chemical_server inner.meeno.net:5000/chemical:1.0

查看是否部署成功

docker logs -f --tail 100 chemical_server
上一篇:Chap03——Nonlinear Programming Concepts Algorithms and Application to Chemical Process


下一篇:Hadoop 初始化集群后,clusterID不一致,报错