Giter VIP home page Giter VIP logo

cicd-git-maven-jenkins-docker's Introduction

CICD-GiT-Maven-Jenkins-Docker

HandsOn Tutorial at: https://youtu.be/eWtpBiOsny4

image

  1. Launch an EC2 instance for Docker host

  2. Install docker on EC2 instance and start services

yum install docker
service docker start
  1. create a new user for Docker management and add him to Docker (default) group
useradd dockeradmin
passwd dockeradmin
usermod -aG docker dockeradmin
  1. Write a Docker file under /opt/docker
mkdir /opt/docker

### vi Dockerfile
# Pull base image 
From tomcat:9-jre9 

# Maintainer
MAINTAINER "DEVOPS with KK" 

# copy war file on to container 
COPY ./webapp.war /usr/local/tomcat/webapps
  1. Login to Jenkins console and add Docker server to execute commands from Jenkins
    Manage Jenkins --> Configure system --> Publish over SSH --> add Docker server and credentials

  2. Create Jenkins job

A) Source Code Management
Repository : https://github.com/khalid-kifayat/CICD-GiT-Maven-Jenkins-Docker.git Branches to build : */main

B) Build Root POM: pom.xml
Goals and options : clean install package

C) send files or execute commands over SSH Name: docker_host
Source files : webapp/target/*.war Remove prefix : webapp/target Remote directory : //opt//docker
Exec command[s] :

docker stop docker_demo;
docker rm -f docker_demo;
docker image rm -f docker_demo;
cd /opt/docker;
docker build -t docker_demo .

D) send files or execute commands over SSH
Name: docker_host
Exec command : docker run -d --name docker_demo -p 8090:8080 docker_demo

  1. Login to Docker host and check images and containers. (no images and containers)

  2. Execute Jenkins job

  3. check images and containers again on Docker host on AWS EC2. This time an image and container get creates through Jenkins job

  4. Access web application from browser which is running on container

<docker_host_Public_IP>:8090

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.