Giter Site home page Giter Site logo

docker-jenkins-tomcat-example's Introduction

Running Jenkins/Tomcat on docker

This is a POC (proof of concept) of a docker network running a Jenkins container which uses a GitHub repository to build a .war file and publish under another container (on the same network) running Tomcat

Tech Stack

  • Docker (latest version)
  • Jenkins (latest version running on Java 8)
  • Tomcat (version 7 running on a Java 8)
  • GitHub (hosting the repository)

Running the project

  1. Clone the repository
  2. Run the following command docker-compose up

This will create the following structure:

Configuring Jenkins

Once everything is up and running (hopefully), it is time to configure Jenkins.

1º Step

After run docker-compose up, it will show something like this:

jenkins_1  | *************************************************************
jenkins_1  | *************************************************************
jenkins_1  | *************************************************************
jenkins_1  |
jenkins_1  | Jenkins initial setup is required. An admin user has been created and a password generated.
jenkins_1  | Please use the following password to proceed to installation:
jenkins_1  |
jenkins_1  | 74b08e697ce94956b9ef949832bxxxx
jenkins_1  |
jenkins_1  | This may also be found at: /var/jenkins_h

ome/secrets/initialAdminPassword
jenkins_1  |
jenkins_1  | *************************************************************
jenkins_1  | *************************************************************
jenkins_1  | *************************************************************

Note the hash, you must copy to the clipboard.

2º Step

Open your browser and hit http://localhost:8180, it will ask for a password (the one that you copy on the 1º Step). Paste and click continue

3º Step

Jenkins will ask for which type of customization, choose Install Suggested Plugins. It will download and install all the required plugins and it may take some time.

4º Step

All the plugins are now installed, time to configure the default user. I recommend to use something basic and simple to remind, like admin/admin, it is a POC, not a production product. Remember, you will need it later on the process ;) Click Save and finish.

5º Step

Our Jenkins is up and running, but we need to make some configurations before start using.

Go to Manage Jenkins on the left menu and them on Global Tool Configuration.

JDK

On the JDK section, click on Add JDK, choose a name (anything), uncheck the config Install automatically and fill the field JAVA_HOME with /docker-java-home

Maven

On the Maven section, click on Add Maven, choose a name (anything), and let Install automatically checked.

Hit apply

Go to Manage Jenkins on the left menu once again and them on Manage Plugin. Click on the Available tab and them, on the search box, type deploy to container. It will show the plugin to install. Select it and click Install without restart

And we are done with configuring Jenkins.

Creating the first job

On the Jenkins home screen, click on New Item on the left menu. Choose a name to the Job and select Freestyle Project and hit ok.

On Source Code Management choose Git and paste the following URL on the Repository URL: https://github.com/kidh0/argentum-web.git. This is the project that we want to build.

On Build, click on Add build step and choose Invoke top-level Maven targets. Select the Maven that you already configured and on Goals type clean package.

On Post-build actions, click on Add post-build actions and choose Deploy war/ear to a container. On the field WAR/EAR files type target/argentum-web.war and in Context path type argentum-web. On Add container, choose Tomcat 7.x. On Credentials click on the add button and create a user with jenkins as username and password. It will be required to the deployment and them select the created user. On Tomcat URL type http://tomcat:8080.

Hit save

Running the first build

Now that we made all the configs required, time to build the project for the first time.

Enter the created job and hit Build now. The first time will be slower than the following builds, it will install all the required dependencies, don't worry.

If we have success on the build (blue dot) we can now go to http://localhost:8280/argentum-web and check if our project exists.

docker-jenkins-tomcat-example's People

Contributors

hboavent avatar henriqueboaventura avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.