Skip to content

Lily-G1/docker-flask-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker-Flask-Demo

Building a python-flask app image with Docker and pushing to Dockerhub using Jenkins CI/CD

docker-flask-demo(2)

To run/test the app manually on an ubuntu/debian server:

To containerize the app using Docker:

  • Install Docker
  • $ cd docker-flask-demo
  • $ docker build -t flask-app . (to build image)
  • $ docker run -d -p 8080:8080 flask-app (to run container)
  • $ docker stop 'container-ID' (to stop container)

To containerize & push app to Dockerhub with Jenkins:

  • Install Jenkins on same server. See installation guide here
  • On the Jenkins U.I, go to Manage Jenkins -> Credentials -> global -> Add Credentials :
    • Kind = ‘username & password’-> Enter your dockerhub account's username & password respectively
    • Id = ‘dockerhub’
    • Description = ‘dockerhub_credentials’. Save.
  • Go to dashboard & create new item (pipeline project) -> Advanced Project Options -> Advanced -> Display Name = ‘Docker-Flask-App’
  • Pipeline -> Pipeline SCM (enter github repo details). Save.
  • Go to Manage Jenkins -> Manage Plugins -> Install ‘safe restart’ plugin
  • On the server's command line:
  • $ sudo usermod -a -G docker Jenkins. Log out & Log back in (to give Jenkins access to Docker)
  • Restart Jenkins using systemctl on the command line OR via the U.I using 'safe restart'
  • Build project
  • Check Dockerhub to confirm that image was pushed successfully

Note:

  • Edit the image name on the Jenkinsfile to your preference

About

Using Jenkins CI/CD to dockerize a python-flask application & push same to Dockerhub

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published