应用服务器在Docker - 与IntelliJ战争部署 [英] Application server in Docker - war deployment with IntelliJ

查看:219
本文介绍了应用服务器在Docker - 与IntelliJ战争部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的亲爱的程序员,



我目前正在使用docker容器来设置我的开发工作,因为我正在Windows上工作,现在我的设置如下:




  • 包括已启动并已运行的jboss的码头服务器映像


  • 在导入IntelliJ的Windows文件系统上检出一个hg代码


  • 映射到docker中的deployment文件夹的共享文件夹图像




每当我想部署我的战争时,我会让IntelliJ构建这个工件作为一个爆炸式的战争与输出目录为$ THE_SHARED_FODLER / mywar.war。然后我将使用mywar.war.deploy在同一个repo中触摸一个文件。由于这是与jboss docker图像的部署文件共享的,所以推出的Jboss现在将部署我的战争。



然而,由于所有IntelliJ都知道我已经构建了一个工件对于一个文件系统,如果我以正常的方式部署了战争(例如,有一个本地jboss和一个jboss运行配置来部署这个爆炸物体),我将无法获得任何可以获得的好的支持。 。前端的东西(html / css)总是可以用咕噜声或类似的方式解决,但是当涉及到jar-libs,到目前为止我所提到的最佳解决方案是:




  • 使用maven重建jar并将其复制到$ THE_SHARED_FOLDER / mywar.war / web-inf / lib /


  • 触摸文件mywar.war.redeploy




然而,这使得周转时间从代码更改到结果约30秒这里是一个非常开放的问题:什么是开发一个应用服务器在Docker映像中运行的好方法?你今天怎么样你尝试过类似的东西,并决定停靠码头集装箱不是这样的方式吗?



任何有关该主题的输入都非常受欢迎: - )



Brgrgs
stevie the TV

解决方案

这是我如何解决您正在上涨的问题:




  • 假设您正在使用 Intellij Docker插件 - 自Intellij 14.1起支持

  • 我是使用 maven 将战争复制到位于我的项目Web应用程序下面的名为 docker 的目录。

  • docker 目录包含用于构建Docker映像的 Dockerfile li>
  • 在Docker文件中,将打包的war文件复制到docker映像,创建管理用户以访问端口 9990 并加载JBoss


  • Dockerfile内容:

      
    FROM jboss / wildfly
    MAINTAINER e.dahari@company.com

    添加您的awesome-app.war / opt / jboss / wildfly / standalone / deployments /

    RUN / opt / jboss / wildfly / bin / add-user.sh admin Admin#70365 --silent

    CMD [/opt/jboss/wildfly/bin/standalone.sh,-b, 0.0.0.0,-bmanagement,0.0.0.0]


  • 现在,您需要创建一个设置文件 container_settings.json 。此文件包含运行您建立的Docker映像的参数:

      
    {
    _comment:我的服务 ,
    Image:your-awesome-app-name,
    HostConfig:{
    PortBindings:{
    9990 / tcp:[{ HostIp:0.0.0.0,HostPort:9990}]
    },
    RestartPolicy:{Name:on-failure,MaximumRetryCount b $ b}


  • 打开Intellij 调试配置并按照 Docker部署 / docker-support-in-intellij-idea-14-1 /rel =nofollow> here

  • container_settings.json的路径应该放在容器设置字段在UI

  • 完成后。您可以运行配置,它将使用刚构建的新的您的awesome-app.war构建您的Docker容器。



请注意,在第一次构建Docker映像后,连续配置运行速度要快得多,因为Docker缓存映像更改。

由于Docker映像中唯一的变化是war文件,所以下一个配置运行将会只传输这部分图像。在Docker文件中的每个操作被缓存时,一般来说,将最多变化的组件放在Docker文件中是很重要的。



希望我有成功的帮助。


Hello dear programmers,

I'm looking into setting up my development with docker containers since I'm currently working on windows, my setup is now as follows:

  • A docker image including a jboss which is started and already running

  • An hg repo checked out on my windows file system which is imported into IntelliJ

  • A shared folder which is mapped to the deploymentfolder in the docker image

Whenever I want to deploy my war, I'll let IntelliJ build the artifact as an exploded war with output directory to $THE_SHARED_FODLER/mywar.war. Then I'll touch a file in the same repo with mywar.war.deploy. Since this is shared to the deploymentfolder of the jboss docker image, the launched Jboss now deploys my war.

However, since all IntelliJ know is that I've built an artifact to a file-system, I can't get any of the nice support that I would get if I'd deployed the war in a normal way (e.g. having a local jboss and a jboss-run-configuration that deployed the exploded artifact). The frontend stuff (html/css) can always be solved with grunt or similar, but when it comes to the jar-libs the best solution I've come up with so far is to:

  • rebuild the jar with maven and copy that to the $THE_SHARED_FOLDER/mywar.war/web-inf/lib/

  • touch a file mywar.war.redeploy

However this makes the turn-around-time from code change to result about 30 secs o here comes a pretty open question: What is a good way to develop towards an application server that is run in a docker image? How do you do today? Have you tried something similar and decided that docker containers is not the way to go for this?

Any input on the subject is highly welcome :-)

Brgrgs stevie the TV

解决方案

Here is how I have solved the issue you are rising:

  • Assuming you are using Intellij Docker plugin - it is supported since Intellij 14.1
  • I am using maven to copy the war to the a directory named docker located under my project web-app.
  • The docker directory contains the Dockerfile for building the Docker image
  • In the Docker file I copy the packaged war file to the docker image, create a management user to access the administration console on port 9990 and load JBoss

  • Dockerfile content:

    
    FROM jboss/wildfly
    MAINTAINER e.dahari@company.com
    ADD your-awesome-app.war /opt/jboss/wildfly/standalone/deployments/
    RUN /opt/jboss/wildfly/bin/add-user.sh admin Admin#70365 --silent
    CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]

  • Now you need to create a settings file container_settings.json. This file contains the parameters to run the Docker image you have built:

    
    {
        "_comment" : "My service",
        "Image": "your-awesome-app-name",
        "HostConfig": {
            "PortBindings":{
                "9990/tcp": [{ "HostIp": "0.0.0.0", "HostPort": "9990" }]
        },
        "RestartPolicy": { "Name": "on-failure", "MaximumRetryCount": 5 }
    }

  • Open Intellij Run/Debug Configurations and add a new Docker Deployment as described here
  • The path to container_settings.json should be placed at Container settings field in the UI
  • Once you have finished. You may run the configuration and it will build your Docker container with the new your-awesome-app.war you have just built.

Please note that after building your Docker image for the first time, successive configuration runs are much faster since Docker caches image changes.
Since the only change in your Docker image is the war file, the next configuration runs will only transfer this part of the image.

In general it is important to put the most changing component last in the Docker file as each action in the Docker file is cached.

Hope I have managed to help.

这篇关于应用服务器在Docker - 与IntelliJ战争部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆