Coder Social home page Coder Social logo

flask-devops-project's Introduction

flask-devops-project

Building and deploying a flask application using Doker, Jenkins and Kubernetes

Configure Jenkins as a service --

Contents of start-agent.sh file -

cd /home/devsidd/jenkins

java -jar agent.jar -jnlpUrl http://192.168.1.8:8080/computer/Ubuntu%2Dnode/jenkins-agent.jnlp -secret 1ca4505451499654cb6680dc9796e411842dd5cc090ae1380a9d56990ead06ed -workDir "/home/devsidd/jenkins"

exit 0

Contents of jenkins-agent.service file -

[Unit]

Description=Jenkins Agent

[Service]

User=devsidd

ExecStart=/bin/bash /home/devsidd/jenkins/start-agent.sh

Restart=always

WorkingDirectory=/home/devsidd/jenkins

[Install]

WantedBy=multi-user.target

Pipeline script ( Jenkins ) --

pipeline {

agent { label 'Ubuntu-node' }

environment {

DOCKER_HUB_REPO = "siddmi0407/flask-hello-world"

CONTAINER_NAME = "flask-hello-world"

}

stages {

stage('Checkout') {

steps {

checkout([$class: 'GitSCM', branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/siddharth07-ui/flask-devops-project.git']]])

}

}

stage('Build') {

steps {

echo 'Building..'

sh 'docker image build -t $DOCKER_HUB_REPO:latest .'

}

}

stage('Testing 1 - Pytest') {

steps {

echo 'Testing..'

sh 'docker stop $CONTAINER_NAME || true'

sh 'docker rm $CONTAINER_NAME || true'

sh 'docker run --name $CONTAINER_NAME $DOCKER_HUB_REPO python -m pytest test.py'

}

}

stage('Testing 2 - Flake8') {

steps {

echo 'Testing..'

sh 'docker stop $CONTAINER_NAME || true'

sh 'docker rm $CONTAINER_NAME || true'

sh 'docker run --name $CONTAINER_NAME $DOCKER_HUB_REPO python -m flake8'

}

}

stage('Deploy') {

steps {

echo 'Deploying....'

sh 'docker stop $CONTAINER_NAME || true'

sh 'docker rm $CONTAINER_NAME || true'

sh 'docker run -d -p 5000:5000 --name $CONTAINER_NAME $DOCKER_HUB_REPO'

}

}

}

}

flask-devops-project's People

Contributors

siddharth07-ui 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.