# Docker Streamlit Application Deployment Using GitHub Actions on AWS Self-Hosted Runner

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1721120656991/03e142bb-7b2f-4276-9c07-190880956c78.png align="center")

This project demonstrates a CI/CD pipeline using GitHub Actions to build a Dockerized Streamlit Python application and deploy it to an AWS EC2 Self Hosted Runner.

**Github Repo link**[🔗](https://emojipedia.org/link)[Docker Deployment using Github Actions](https://github.com/Raghul-M/Docker_Github-Actions_AWS-App/)

**Project Workflow :**

1. **Code Commit:** Developers push code changes to the `main` branch.
    
2. **CI Build Job**: GitHub Actions triggers a build job (`build.yml`) upon code commit.
    
3. **Docker Image Build**: The CI job builds a Docker image from the Dockerfile and pushes it to Docker Hub upon successful build.
    
4. **CD Deploy Job**: After the image is pushed, another GitHub Actions job (`deploy.yml`) is triggered.
    
5. **Deployment to AWS EC2**:
    
    * The deploy job uses a self-hosted runner on an AWS EC2 instance.
        
    * It pulls the latest Docker image from Docker Hub.
        
    * The image is then run as a container on the EC2 instance.
        

![Screenshot from 2024-06-29 13-38-02](https://github.com/Raghul-M/Docker_Github-Actions_AWS-App/assets/71755586/060fa7d3-5506-4cb7-afbd-bd3c90c21936 align="left")

**Repository Structure:**

* `.github/workflows/`: Contains GitHub Actions workflows.
    
    * `build.yml`: Defines CI build steps.
        
    * `deploy.yml`: Defines CD deployment steps.
        
* `Dockerfile`: Configuration for building the Docker image.
    
* [`README.md`](http://README.md): Project documentation (you are currently reading this file).
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1721121142586/f884d0b2-464a-41ab-a83e-d7069608a40f.png align="center")
    

**Prerequisites:**

Before running the CI/CD pipeline, ensure you have set up the following:

* **GitHub Repository**: Configure secrets for Docker Hub credentials (`DOCKER_USERNAME`, `DOCKER_PASSWORD`) as Repo Secrets.
    
* **Docker Hub Account**: Repository for storing Docker images.
    
* **AWS EC2 Instance**: Ensure the instance is running and accessible via SSH and Configured Self-Hosted Runner
    

![Screenshot from 2024-06-29 13-39-57](https://private-user-images.githubusercontent.com/71755586/344378945-2fc78c78-2f88-47b7-909c-d4a49a4fb220.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExMjE0MTEsIm5iZiI6MTcyMTEyMTExMSwicGF0aCI6Ii83MTc1NTU4Ni8zNDQzNzg5NDUtMmZjNzhjNzgtMmY4OC00N2I3LTkwOWMtZDRhNDlhNGZiMjIwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE2VDA5MTE1MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWVjMGY2M2M0N2RjMmQyNmY4ODAwY2UwMzAwYzdiMGZhYjU3YzJkNzkxYjg3NDAxZGVlMTc3MjIyNGQ2MzUyMmUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.vGSAVVlQVxzX2FKr2amlv77X1sOUw1sLau__bCLHZd0 align="left")

**Final Deployment :**

![Screenshot from 2024-06-29 13-25-03](https://private-user-images.githubusercontent.com/71755586/344378991-c0cf36d7-9807-4d35-aee9-8e65c1fd4bb7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExMjE0MTEsIm5iZiI6MTcyMTEyMTExMSwicGF0aCI6Ii83MTc1NTU4Ni8zNDQzNzg5OTEtYzBjZjM2ZDctOTgwNy00ZDM1LWFlZTktOGU2NWMxZmQ0YmI3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE2VDA5MTE1MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ5NzRlOTNmZWY5ODEzY2Y3YTcwMDk5ZThjNWVhMzRjYzg1ZDdmMWE2OTNkZjI4MTlhM2U4Y2ViMjZiZTU5MzImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.x5VCdpgzfR7g1dxfaoHar9FJkDCivqLJI6TFvKWCZL0 align="left")

**Notes**

* Ensure that your Dockerfile is configured correctly to build and run your Python application.
    
* Regularly monitor and maintain your AWS EC2 instance to ensure proper functioning of the deployed application.
    

## Contributing

Contributions are welcome! If you have suggestions, bug reports, or want to add new features, feel free to submit a pull request.

Feel free to explore, contribute, and adapt this project to suit your needs. If you encounter any issues or have suggestions for improvement, please raise them in the GitHub repository's issues section. Happy coding! 🚀

Connect with me on Linkedin: [Raghul M](https://www.linkedin.com/in/m-raghul/)
