IDEA使用Docker配置项目远程部署
服务器安装Docker,添加配置并重启
1
vim /etc/default/docker DOCKER_OPTS="-H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375"
添加Tomcat
1
docker run tomcat
IDEA安装Docker插件,需重启后生效
在项目目录下创建docker-dir目录,并创建Dockerfile文件,其内容为:
1
#build FROM tomcat RUN mkdir /root/.m2 WORKDIR /root/.m2 RUN wget http://10.168.2.64/scripts/settings.xml WORKDIR /usr/sbin RUN wget http://10.168.2.64/soft/html2pdf RUN chmod 755 html2pdf RUN apt-get update RUN apt-get -y install ghostscript ENV CATALINA_OPTS "-agentlib:jdwp=transport=dt_socket,address=0.0.0.0:18787,suspend=n,server=y" EXPOSE 18787 RUN apt-get -y install ssh RUN sed -i /Port/s/22/2022/ /etc/ssh/sshd_config RUN sed -i /PermitRootLogin/s/without-password/yes/ /etc/ssh/sshd_config EXPOSE 2022 RUN sed -i /exit/d /etc/rc.local RUN echo "root:root" | chpasswd RUN sed -i /^PRGDIR/a'service ssh restart' /usr/local/tomcat/bin/catalina.sh ADD SCM-usorder.war /usr/local/tomcat/webapps/
Settings > Build,Execution,Deployment > Clouds下增加docker,如图:
Edit Configuration > New Docker Deployment
修改war的输出目录[ctrl+shift+alt+S]
官方教程
官方教程