I started learning devops recently. Guys I have a doubt here please solve. After testing Jenkins package everything including code and dependencies into a war/jar file. Even dockerfile contains application's source code and dependencies. Now if we are using the docker container to deploy onto production server. Now where do we use the war file that is generated from JEnkins? someone please clarify.
So lets take Jenkins itself as an example. you can download jenkins.war but still you need a place to host this war file so you can use docker for that. think of it as an alternative for virtual machines.
So the jar file that you have generated through jenkins build needs java or tomcat or whatever external dependencies to be up and running docker can do that for you. Take a look at the following example:
Run a Simple .jar Application in a Docker Container
Related
I've a simple REST API in the weblogic application. I've to deploy the application as the docker container. But, I'm facing a problem in defining the Dockerfile.
Dockerfile
FROM store/oracle/weblogic:12.2.1.4
COPY target/app.war /u01/oracle
Above is my current Dockerfile. With the current dockerfile, I have to manually deploy the application on the weblogic server. We would like to automate the application deployment using Dockerfile and didn't get the exact examples.
Please advise.
This is a complex task, so it is hard to explain the whole process here.
The high-level steps that you need to execute are the followings:
Start a properly configured WebLogic domain in Docker. This task involves the creation of the admin and managed servers and WL cluster, etc.
Build the application that you wanna deploy
Configure the database properly if you have any
Create the WL resources like connection pool, JMS, etc manually or via WLST script
Deploy your artifact via the WL web console or with WLST script or copy the file under the autodeploy directory
Be careful because the tasks that you executed manually will be lost if you drop your docker container.
You can find concrete examples, use cases, automated scripts that you can use and well prepared, ready for use WebLogic Docker images here: https://github.com/zappee/docker-images
If you have a concrete question, not a general one, like this, then please start a new thread.
Take a look at the GitHub project:
https://github.com/oracle/docker-images/tree/master/OracleWebLogic/dockerfiles
I'm building Jenkins pipeline and after pipeline fails with server installation some logs are generated on machine where server is being installed.
I want to attach those logs to Jenkins build so person can see that file from Jenkins build only instead of going to machine and find it out.
I saw a plugin Copy To Slave Plugin but for installation when I searched for it in Jenkins, it's not listed.
Could you please suggest which plugin will help me to attach log files to Jenkins build?
Due to the complex nature of filesystems, Jenkins is not capable to copy logs from extraneous locations like those outside of the Jenkins root directory. This is for security reasons, which is why the Copy to Slave Plugin you referred to earlier has been discontinued.
In short, Jenkins spawns processes that spawn other processes that are owned by different users in the filesystem (e.g. root). For this reason, it is highly probable that the log files you are referring to are located elsewhere on the file system (i.e. not in $JENKINS_HOME), and thus are not owned by the jenkins user.
It is possible to use cat or tail on the log files in the Jenkins build itself. In combination with a plugin like Log Parser, this can provide some nice output in another screen.
I would be interested about what do you mean by “install”? Can the install happen during the building of a Docker image? Or in a pre-built Docker container? If this is the case, you can copy the “installed” files to the destination.
This would help you, because any log files created during the “install” can be copied out from the docker container and attached to the Jenkins build as an archived artifact.
For this, you don’t even need a plug-in.
I have a machine with blocked outgoing connections so it is not possible to update jenkins nor install the plugins I need for my work.
My idea is the following: I download the jenkins .war on my personal laptop and complete the installation + the plugin download.
Then I just move this .war to the machine where I need jenkins to be up and running.
Is it possible? Where are the plugins/updated data stored?
Also, would it be a problem the fact that my laptop has windows as os, while the destination machine is a linux RHEL?
Your solution sounds crazy :D
This could be help you:
Update Jenkins war
If you have shell access with root privilege, there is a manual way.
Download latest war file inside your linux, using wget , curl or just upload it using winscp from your windows.
Stop jenkins
Backup EVERYTHING: linux snapshot, jenkins workspace, jenkins war file, etc
Replace the old war with new war
Start jenkins
Detailed steps in this webs:
https://mohitgoyal.co/2017/02/15/upgrade-jenkins-server-to-a-new-version/
https://www.thegeekstuff.com/2016/06/upgrade-jenkins-and-plugins/
Plugin
Jenkins has an option to install plugins called Manage Plugins
This offer two options :
(1) Install plugins using available option
For official and compatible plugins, suggested by Jenkins :
(2) Install plugins using upload option
For custom plugins or when is not available on official repositories:
Short question: is it ok (aren't there any contradictions with Docker ideology) to compile and start application from sources inside Docker container?
Assume that I have some hypothetical application. Let it be Java web service built with Maven, located somewhere in GitHub. Specifics doesn't matter here.
But before starting this service, I need to set-up several config files with right parameters, known at deployment time. Right now I can build fully-preconfigured application package with a single maven command, passing all the necessary configurations at build command.
Now assume that I need to make it a Docker container and don't have time to refactor it somehow right now. So I have a plan: let my docker image have Maven and Git, ENTRYSCRIPT clones my Git repository, builds and starts the application, passing all the necessary parameters via environment.
Is it suitable plan, or it's just wrong?
I am new to docker. I have a Spring-boot application which I want to deploy and run using docker. Is it a good practice to put war file images in the container or it is better to put jar ones? why?
P.S. Once I read that it is better to "make jars , not wars" :-) but do not know the reason behind it.
One of the main reasons for building a docker image for your application is to provide an artefact that people can run without installing and managing external software dependencies (like an app server to run a war file).
From a container user perspective, it makes no difference whether you package your code in a jar or a war file or as a fortran binary. All they do is run a container image.
From your side, doing the Docker build and config management, packaging a jar file and copying will be a more simple solution than trying to setup and configure an app server to package then deploying each release into the app server. See Ohmens answer for some more technical components of the java build.
Matt's answer is correct, but you have to consider some further points.
Updates to the applicationserver: docker images of tomcat or glassfish are maintained by the responsible companies. If they find a nasty (security) bug they fix it and push a new version of that image to docker hub. To update your container to that secure version all you have to do is to rebuild your image and run a new version. If you bundle the applicationserver inside a jar you have to recompile your whole project to use that updated version. BTW most applicationservers have a autodeploy mechanism to deploy war's easily.
Dockers cache: if you build an image from a java base image and simply copy your fat jar on it, your whole image consists of one big layer. If you build another version of your app the big jar file changes causing docker to create another big layer. These two big layers both need space on your disc. On the other hand if you deploy a "small" war file to an applicationserver the two images share all layers until the layer with the war file. With these mechanism does docker improve your disc usage and speed up build times.