# Python Image for Continuous Delivery This project involves creating a Docker image that automates continuous delivery by pulling code from a Git repository's master branch and running a Python script from that branch. Additionally, it provides a Git hook route where a Githook can post notifications about changes on the master branch. The system stops the Python script, pulls the latest changes, and then restarts the script. ## Use Cases The primary use case is to simplify hosting and updating a webserver. Development can take place on a development branch, and when everything is working fine locally, merging changes into the master branch will trigger an automatic server update. ## Implementation To achieve this, an entry script is used to clone the specified Git repository and start two scripts. One is a Flask web server that listens for POST requests to trigger updates, and the other is a Python script from the Git repository. Both scripts are managed by Supervisord. ### Entry Script (entryscript.sh) The entry script performs the following steps: 1. Clones the specified Git repository. 2. Starts Supervisord to manage the two scripts. ### Supervisord Configuration (supervisord.conf) The Supervisord configuration sets up the management of the two scripts: - `/home/githook/githook.py`: A script for handling Git hooks. - `/home/app/app.py`: The main Python script from the Git repository. ### Githook Configuration (githook.py) The Githook script listens on port 5000 for incoming Git hook notifications. ## How to Build To build the Docker image, use the following command: ```bash docker build -t [your_image_name] . ``` ## How to Run To run the Docker container and initiate the continuous delivery process, use the following command: ```bash docker run -it --rm -p 5000:5000 -e GIT_REPO=http://some-repo.url/path/to/repo [your_image_name]:latest ``` ## Logging If necessary, Supervisord can log output to `/var/log`. You can mount a volume to access these log files if needed. ## Parameters The following parameters are relevant to the Docker image and environment: - `/app.py`: The starting script in the Git repository. - `GIT_REPO`: A Docker environment variable specifying the Git repository URL. - `5000`: The port used to listen for Githook POST requests. - `/var/log/`: The path to log files.