Skip to content

A hacked together flask api in a docker container

License

Notifications You must be signed in to change notification settings

Masquerainsley/jenkins-workshop

 
 

Repository files navigation

An Introduction to Jenkins & Continous Integration

Just a little something to introduce some people to CI/CD with Jenkins

Requirements

You will need Docker and Docker Compose, check you have both with this command...

docker -v && docker-compose -v 

Preparation

Fork https://github.com/WillGibson/jenkins-workshop to your GitHub account, clone your fork. to your machine and cd jenkins-workshop.

Sample App

A hacked together Flask API in a docker container

Build: ./build.sh

Run: ./run.sh

Test: ./dockertest.sh

Jenkins

Setting up Jenkins

  • Move into the jenkins folder cd jenkins

  • Fire up Jenkins in a Docker container with Docker Compose docker-compose up

  • Hit http://localhost:8080/ and log in with the admin password you got in the output from the previous command

  • Install suggested plugins

  • Create your admin user and click through past "Save and continue"

Setting up our pipeline

  • Click "Create a job"

  • Enter a name, select "Pipeline" and click "OK"

  • General

    • Check "Do not allow concurrent builds"

    • Check "GitHub project" and enter the URL "https://github.com/<your_github_username>/jenkins-workshop"

    • Check "This project is parameterised"

      • Select "String parameter"
      • Enter "BRANCH" for the name
      • Enter "master" as the default
  • Build Triggers

    • Ignore this for now
  • Advanced Project Options

    • Ignore this for now
  • Pipeline

    • Select "Pipeline script from SCM" (Source Code Management)

    • Enter the repository URL "https://github.com/<your_github_username>/jenkins-workshop"

    • Delete the "Branch Specifier" (so it can build any branch based on the branch parameter)

    • Uncheck "Lightweight checkout"

  • Click "Save"

Deploying to Heroku

  • (Create a Heroku account](https://signup.heroku.com/login)

  • Create a Heroku app

  • Set the stack of your app to container heroku stack:set container

  • Connect the app to your Git repository

  • Create a deploy key

  • Add the deploy key to you GitHub repo with write access

Useful commands

  • Log into the jenkins container docker exec -it jenkins_workshop /bin/bash

  • Run the Jenkins container in the background docker-compose up -d

  • Stop the Jenkins container if you ran it in the background docker-compose down

References

About

A hacked together flask api in a docker container

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dockerfile 58.9%
  • Python 29.1%
  • Shell 12.0%