Docker | How to build and deploy war file in jboss container hosted in Docker - maven

I have a jboss image hosted in Docker, along with several others. I am able to run the jboss image and use it as container to deploy webapps.
Currently using IntelliJ to configure a Docker configuration and deploy war files directly from IntelliJ and pointing to the docker configuration within IntelliJ.
I am looking for ways by which I can deploy this war file directly in my jboss image at Docker.
Basically looking at ways to deploy war file without any IntelliJ intervention, with the use of docker-compose to build jboss image along with added war targets successfully deployed.
What sort of changes need to be done in jboss.yml file and Dockerfile for jboss image?

If you want the .war file to be integral part of your image, then you just need to add it as a file resource to your jboss deployment dir during your image assembly via dockerfile. Say your docker file goes like this:
FROM jboss/wildfly
COPY myapp.war /opt/jboss/wildfly/standalone/deployments/
Of course you need to adjust the paths to match your setup and distribution, you can for example use maven docker plugin.
Other option is just to build your server without any deployments and use jboss cli or web admin interface to deploy it. Again you can automate it via maven or RUN command in dockerfile.

Related

Why does my jar file run wrong in docker?

I have a working jar that runs fine with java -jar my-file-jar-name.jar .
However, the problems start when I try to push it into a docker container.
The container is built successfully, but when I run the container itself at 8080, I only see "Whitelabel Error Page".
I suspect that the problem is that in addition to the jar file itself, additional resources are needed, such as web pages (jsp & css).
How can I do it?
My Dockerfile
FROM openjdk
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
CMD ["java","-jar","/app.jar"]
P.S. I saw in one thread that web applications need war packaging, but 100 other resources say that spring boot applications are packaging by jar. Where is the truth?
I tried to change the jdk version, the way to build the archive (jar to war). The most interesting thing is that with a zero project, like helloworld, everything works. And docker runs everything just fine. However, my application is much more complex and it is the one I need to package.

How to redeploy WAR inside a JBoss WildFly container?

I am trying to make my local Java development environment more lighter.
Dockerfile multi-stage steps looks like this:
MAVEN CONTAINER
build app from source code
WILDFLY CONTAINER
prepare server (data sources, drivers)
copy WAR from MAVEN
start server and deploy application
This usually takes about 1-3 minutes, even with dependencies-offline-mode.
After making some code changes I have two options - build new image (1-3 minutes) or manually build WAR and redeploy app from WildFly Administration Panel. Is there any tool to automate this?
Maybe this basic approach will be enough:
0. start local env as always
1. make some code changes
2. build WAR in MAVEN conotainer
3. copy WAR into WILDFLY container
4. enter WILDFLY container bash and redeploy using JBOSS-CLI
Are you using some Maven plugins? Bash scripts? Thank you for hints!

How to I externalize my configuration for my spring-boot war application?

I have a spring-boot war application that is packaged using Maven, and I need to deploy it as docker image. Now I am done with creating docker image, my current problem is how do I pass external configuration? I am not running my spring-boot application as java -jar myapp.war. The person responsible for deploying this image will need to pass the path of the configuration file to docker image.

How to manage custom common libraries built in maven for my Application in kubernetes

I need to understand how to deal with common libraries that i have created which my Application depends upon. When i create jar for this app using maven it creates a package. But how do we maintain or configure other common libraries which are listed in pom.xml of this application?
should we have maven also as an image in the docker file?
Please explain in detail.
My current progress is explained below: I have an Application A which has other dependencies like B and C libraries which i have specified in pom.xml. When i run application A in my local system it uses local repository that i have configured in user settings for maven. SO it works fine.
So how do we maintain this in kubenetes.
The images that you use to build the containers that run on Kubernetes should contain everything that's needed to run the application.
When you create the JAR file for your application, this JAR should contain the dependencies. There are different ways to achieve this, using both Maven or Gradle. This is an example using Maven and its Apache Maven Assembly Plugin. This is another good user guide on how to achieve it.
Then, you need to create a container image that can run that JAR file, something like
FROM openjdk:8-jdk-alpine
EXPOSE 8080
WORKDIR /opt/app
CMD ["java", "-jar", "app.jar"]
COPY build/libs/app.jar /opt/app
Once this container image is published on a registry, whenever Kubernetes needs to schedule and create a container, it will just use that image: there is no need to re-compile the application and its dependencies.

Deploy to weblogic using maven and jenkins

We are using Jenkins in our project for build and deployment on dev environments. I have sucessfullly created a war file using maven in jenkins and now I have to create another job to deploy that war file into the weblogic server.
However, I am not aware of the required steps for configuring this job in jenkins. Will it be a matter of just invoking a maven deploy command? Can some one please tell me what will be the required steps to deploy a war file into weblogic 10.3.5 using jenkins?
edit : The approach we are following is after creating the war file we are cheking the war file created into svn and then the deploy job will take the war file from there and deploy it into the weblogic. Does some one thing there is a better way of doing thhings than this?
Thanks,
Manish
Use the Jenkins "Weblogic Deployer Plugin". This will do the deployment for you. All you need to do is specify:
Task Name: Give the deployment a name; Eg. Webapp WL Deployment
Environment: Specify the environment you are deploying to. Make sure you are using the AdminServer port number and not the Managed Server port number; default is 7001
Name: The name weblogic should use for your webapp to display the deployed component
Built resource to deploy: The file name of your webapp. You can use also use regular expressions for this
Targets: The name of the managed server you want to deploy the webapp to
Weblogic libraries: Whether or not the webapp should be deployed as a library component.

Resources