Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile在网易云无法使用 #1

Open
downgoon opened this issue Jan 11, 2017 · 1 comment
Open

Dockerfile在网易云无法使用 #1

downgoon opened this issue Jan 11, 2017 · 1 comment

Comments

@downgoon
Copy link
Owner

downgoon commented Jan 11, 2017

本处 Dockerfile 在网易云中无法使用,表现为“构建镜像的过程特别漫长,并最终中断”。

此Dockerfile继承网易云Tomcat7的基础镜像,然后执行 mvn package && cp -rf ~/java/jresty-rest-example/target/jresty-rest-example-*.war $TOMCAT_ROOT

构建镜像的时候做了编译工作,实际上这不太符合常规做法。常规做法应该是在编译集群上编译,然后把编译好的包分发到Docker集群,整个流程由Jenkins来引导。只是网易云目前不支持Jenkins引导编译

有两种办法:

  • 在本地构建镜像,然后把镜像发布到网易云。
  • 把编译好的结果上传到github,然后在Dockerfile中去掉编译指令,最后让网易云去下载github项目,并执行Dockerfile。

备注:

  • Dockerfile 中执行mvn package指令,不提倡 !!!
  • Jenkins引导:
    • 从github下载代码
    • 在编译集群上编译
    • 组装Docker镜像
    • 容器部署
@downgoon
Copy link
Owner Author

downgoon commented Jan 11, 2017

Dockerfile

###
# To build:
#    docker build -t downgoon/jresty-ping .
# 
# To run: 	
# 	docker run -t -i -p 8080:8080 downgoon/jresty-ping
###



FROM  hub.c.163.com/public/tomcat:7.0.28
MAINTAINER netease

# install maven and jdk7    
RUN apt-get update && apt-get install -y maven openjdk-7-jdk    

# Set the location of the tomcat
ENV TOMCAT_ROOT /var/lib/tomcat7/webapps/ROOT/

# expose http port
EXPOSE 8080

COPY . ~/java
WORKDIR ~/java
    
RUN mvn package && cp -rf ~/java/jresty-rest-example/target/jresty-rest-example-*.war $TOMCAT_ROOT
ENTRYPOINT /etc/init.d/tomcat7 start

执行慢的地方是 ? mvn package,原因是在镜像中安装maven后,并没有在 settings.xml 配置中央库的国内镜像站点,导致依赖下载速度非常慢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant