The app is currently running on AWS: http://18.117.71.156:8787/
Jenkins job on AWS: http://18.117.71.156:8080/job/python-app-pipeline/
The repository contains:
- Basic Python Flask app in Docker which prints the hostname and IP of the container
- A Dockerfile to dockerize and run the application
- A Jenkinsfile for the CI flow cofiguration
- Windows 10+ OS
- Java version 8 or 11 installed - https://jdk.java.net/java-se-ri/11
- Python installed on the host machine - https://www.python.org/downloads/
- Docker Engine installed - https://docs.docker.com/desktop/windows/install/
$ git clone https://github.com/kyenzo/python-flask-docker
- Download the Jenkins client to your machine Jenkins.war
- Open the terminal in the directory of the Jenkins client and run:
$ java -jar jenkins.war --httpPort=8383
- Go to http://localhost:8383
- Setup the 1 time password for Jenkins from the installation log
- Example: bd389e2f59b040abaa45e2662514fb41
- Create an admin user
- In the Jenkins Dashboard - Go to Manage Jenkins > Manage Credentials
- Click on the (Global) drop-down > Add Credentials
- Set up the GitHub Username and Password
- The ID field is a placeholder for the password in the pipeline - Set to: GIT_HUB_CREDENTIALS
- Save
- In the Jenkins Dashboard - Click on New Item
- Insert a name and choose Pipeline
- Go to Pipeline section and choose Pipeline script from SCM, in the description
- SCM = Git
- Repository URL = https://github.com/kyenzo/python-flask-docker.git
- Choose the credentials you've created
- Since the Jenkins cliend is installed locally - GitHub hook trigger for GITScm polling, is not possible.
- Make sure that the Docker engine is running
- Click build now
- Go to http://localhost:8787
$ git clone https://github.com/lvthillo/python-flask-docker.git
$ docker build -t lvthillo/python-flask-docker .
You can also just download the existing image from DockerHub.
docker pull lvthillo/python-flask-docker
Create a container from the image.
$ docker run --name my-container -d -p 8080:8080 lvthillo/python-flask-docker
Now visit http://localhost:8080
The hostname of the container is 6095273a4e9b and its IP is 172.17.0.2.
Verify by checking the container ip and hostname (ID):
$ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' my-container
172.17.0.2
$ docker inspect -f '{{ .Config.Hostname }}' my-container
6095273a4e9b