我目前在CI中使用jenkins
1)查看github的代码
2)进行静态分析
3)建立jar文件
4)创建docker文件并创建docker image
5)将docker文件推送到私有docker注册表
我有三个微服务,我发现每个jenkins作业运行时,它会在jenkins服务器上创建图像,成本为1.8 GB。
sudo docker images
dockerrepo:5000/reward 1 94791f0ea2f7 13 hours ago 682 MB
dockerrepo:5000/reward latest 94791f0ea2f7 13 hours ago 682 MB
dockerrepo:5000/mission 1 3f5f81975f60 13 hours ago 682 MB
dockerrepo:5000/mission latest 3f5f81975f60 13 hours ago 682 MB
dockerrepo:5000/employee 1 51ba73ad9f48 13 hours ago 695.4 MB
dockerrepo:5000/employee latest 51ba73ad9f48 13 hours ago 695.4 MB
dockerrepo:5000/reward <none> 81a9d4287823 19 hours ago 682 MB
dockerrepo:5000/mission <none> 8bde5a7db299 19 hours ago 682 MB
dockerrepo:5000/employee <none> 0468a6fdb274 19 hours ago 695.4 MB
dockerrepo:5000/reward <none> 90aafe222219 20 hours ago 682 MB
dockerrepo:5000/mission <none> 993fbe1add06 20 hours ago 682 MB
dockerrepo:5000/employee <none> ed3e79c4358d 20 hours ago 695.4 MB
dockerrepo:5000/reward <none> 55ee8ff2e862 21 hours ago 682 MB
dockerrepo:5000/mission <none> cd916601c5ae 21 hours ago 682 MB
dockerrepo:5000/employee <none> c161547cb40f 21 hours ago 695.4 MB
dockerrepo:5000/reward <none> 0ab760a9c1da 24 hours ago 682 MB
dockerrepo:5000/mission <none> 379f403173ec 24 hours ago 682 MB
dockerrepo:5000/employee <none> 59611b29e023 24 hours ago 695.4 MB
dockerrepo:5000/reward <none> d4782e03237c 25 hours ago 682 MB
dockerrepo:5000/mission <none> 3da34e04c5fa 25 hours ago 682 MB
dockerrepo:5000/employee <none> 683104822e13 25 hours ago 695.4 MB
dockerrepo:5000/reward <none> a9c10a0b4376 42 hours ago 682 MB
dockerrepo:5000/mission <none> 5818f60cc0db 42 hours ago 682 MB
dockerrepo:5000/employee <none> e819c78da2fc 42 hours ago 695.4 MB
用于单个微服务的Docker文件
FROM java:8
VOLUME /tmp
ADD Mission/target/Mission.jar missionfinal.jar
RUN bash -c 'touch /missionfinal.jar'
EXPOSE 8081
ENTRYPOINT ["java","-Dspring.data.mongodb.uri=mongodb://mongodb/microservices", "-Djava.security.egd=file:/dev/./urandom","-jar","/missionfinal.jar"]
现在我有16 GB的图像并且它将会增长,这只是一个POC,我无法想象它们如何为数百个微服务做。
是一个简单的解决方案,一旦将它推送到存储库,就会从jenkins服务器中删除它吗?任何其他提示和建议,以改善这一过程。
感谢。