Git Product home page Git Product logo

devops-project-3's Introduction

Simple DevOps Project.

Integration with Git, Maven, Jenkins, Ansible, and Docker

image

Pre-Requisites:

  1. Docker installed on ansible server

  2. login to "docker hub" on ansible server

  3. Create Jenkins job,

    • Source Code Management:
      • Repository : ``
      • Branches to build : */main
    • Build:
      • Root POM:pom.xml
      • Goals and options : clean install package
    • Post Steps
      • Send files or execute commands over SSH

        • Name: Ansible server
        • Source files : webapp/target/*.war
        • Remove prefix : webapp/target
        • Remote directory : //opt//docker
      • Send files or execute commands over SSH

        • Name: Ansible serverr
        • Source files : Dockerfile
        • Remote directory : //opt//docker
        • Exec Command:
          • cd /opt/docker
          • sudo docker build -t $JOB_NAME .
          • sudo docker tag $JOB_NAME sourabhmiraje/$JOB_NAME:$BUILD_ID
          • sudo docker tag $JOB_NAME sourabhmiraje/$JOB_NAME:latest
          • sudo docker push sourabhmiraje/$JOB_NAME:$BUILD_ID
          • sudo docker push sourabhmiraje/$JOB_NAME:latest
          • sudo docker rmi -f sourabhmiraje/$JOB_NAME:latest
          • sudo docker rmi -f sourabhmiraje/$JOB_NAME:$BUILD_ID
          • sudo docker rmi -f $JOB_NAME

Part-02 : Deploy Containers

  1. Write a yaml file to create a container (file name : playbook.yaml)
      ---
      - hosts: docker
        tasks:
           - name: Stop a container
             community.docker.docker_container:
               name: myapp
               state: stopped
             ignore_errors: yes
    
           - name: Remove container from all networks
             community.docker.docker_container:
               name: myapp
               purge_networks: yes
             ignore_errors: yes
    
           - name: Remove image
             community.docker.docker_image:
               state: absent
               force_absent: yes
               name: sourabhmiraje/project_4
               tag: latest
             ignore_errors: yes
    
           - name: Start a container with a command
             community.docker.docker_container:
               name: myapp
               image: sourabhmiraje/project_4
               ports: 8090:8080
    
  2. Run playbook on Ansible server.
    • Under post build actions
      • Send files or execute commands over SSH
        • Exec Command:
           cd /opt/playbooks
           ansible-playbook create_docker_container.yml

devops-project-3's People

Contributors

sourabh-the-creator avatar

Watchers

 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.