Deploying A Fastapi Application With Ci Cd Pipeline Hng Task 2

Leo Migdal
-
deploying a fastapi application with ci cd pipeline hng task 2

In this article, I will walk you through how I deployed a FastAPI application with continuous integration (CI) and continuous deployment (CD). The first step is to fork the repo and clone the repository to your local device git clone https://github.com/hng12-devbotops/fastapi-book-project.git cd fastapi-book-project/ I am testing the application locally before deploying, using a virtual environment is the best practice to manage your Python dependencies. To do this you need to create and activate a virtual environment. python3 -m venv hng source hng/bin/activate Our API is currently unable to fetch a single book using its ID.

In this step, I added a new endpoint to the FastAPI router that handles a GET request to retrieve a book based on its provided ID. Add this code to the books.pyfile Once you've implemented the endpoint, it's important to test it to ensure it behaves as expected, I did this by running this command pytest This is a FastAPI application deployed with a CI/CD pipeline for managing a book collection. It provides comprehensive CRUD (Create, Read, Update, Delete) operations for books with proper error handling, input validation, and documentation. The application is publicly accessible and uses Nginx as a reverse proxy for improved performance and security.

The application is deployed on Render and is publicly accessible. Nginx is configured as a reverse proxy to: The nginx.conf file is used to configure Nginx as a reverse proxy. Here's a snippet of the configuration: The CI/CD pipeline is set up using GitHub Actions: FastAPI provides an interactive Swagger UI:

As part of the HNG DevOps internship, Stage 2 required deploying a FastAPI application using Docker and setting up a CI/CD pipeline via GitHub Actions. This was an exciting challenge that tested my skills in cloud infrastructure, automation, and debugging under real-world conditions. The project had several key requirements: The first challenge was implementing the missing endpoint to retrieve a book by ID. The solution required careful consideration of error handling and response formatting: The CI/CD setup was fascinating.

I used GitHub Actions to create two essential workflows: A key part of this challenge was containerizing the FastAPI application to ensure consistent deployment. The Dockerfile used was as follows: © 2025. Sober Group is a registered DBA of MyNew Technologies, LLC, a technology firm based in Illinois. We build software tools and community portals, but do not offer any medical, clinical, or counseling services.

This project is a RESTful API built with FastAPI for managing a book collection. It provides comprehensive CRUD (Create, Read, Update, Delete) operations for books with proper error handling, input validation, and documentation. The API includes proper error handling for: This project is licensed under the MIT License - see the LICENSE file for details. For support, please open an issue in the GitHub repository. Tired of manually deploying your applications?

What if you could push code to GitHub, run tests automatically, and deploy updates to your live server—without lifting a finger? That’s exactly what I did with my FastAPI project using CI/CD. I’ll walk you through how I set up a Continuous Integration (CI) pipeline to automatically test my code... Continuous Deployment (CD) pipeline to push updates to an AWS EC2 instance. Join the DZone community and get the full member experience. Deploying FastAPI apps manually gets old fast.

You SSH into a server, pull the latest code, restart the service, and hope nothing breaks. Maybe you remember to run tests first. Maybe you don't. One forgotten environment variable or skipped test, and your API is down. Users get 500 errors. You're frantically SSHing back in to fix it.

GitHub Actions can automate the entire deployment process. Push to your main branch, tests run automatically, and if they pass, your app deploys. No SSH. No manual steps. No forgotten checks. We'll use a simple FastAPI app to demonstrate the pipeline.

Your actual app will be more complex, but the deployment process stays the same.

People Also Search

In This Article, I Will Walk You Through How I

In this article, I will walk you through how I deployed a FastAPI application with continuous integration (CI) and continuous deployment (CD). The first step is to fork the repo and clone the repository to your local device git clone https://github.com/hng12-devbotops/fastapi-book-project.git cd fastapi-book-project/ I am testing the application locally before deploying, using a virtual environmen...

In This Step, I Added A New Endpoint To The

In this step, I added a new endpoint to the FastAPI router that handles a GET request to retrieve a book based on its provided ID. Add this code to the books.pyfile Once you've implemented the endpoint, it's important to test it to ensure it behaves as expected, I did this by running this command pytest This is a FastAPI application deployed with a CI/CD pipeline for managing a book collection. It...

The Application Is Deployed On Render And Is Publicly Accessible.

The application is deployed on Render and is publicly accessible. Nginx is configured as a reverse proxy to: The nginx.conf file is used to configure Nginx as a reverse proxy. Here's a snippet of the configuration: The CI/CD pipeline is set up using GitHub Actions: FastAPI provides an interactive Swagger UI:

As Part Of The HNG DevOps Internship, Stage 2 Required

As part of the HNG DevOps internship, Stage 2 required deploying a FastAPI application using Docker and setting up a CI/CD pipeline via GitHub Actions. This was an exciting challenge that tested my skills in cloud infrastructure, automation, and debugging under real-world conditions. The project had several key requirements: The first challenge was implementing the missing endpoint to retrieve a b...

I Used GitHub Actions To Create Two Essential Workflows: A

I used GitHub Actions to create two essential workflows: A key part of this challenge was containerizing the FastAPI application to ensure consistent deployment. The Dockerfile used was as follows: © 2025. Sober Group is a registered DBA of MyNew Technologies, LLC, a technology firm based in Illinois. We build software tools and community portals, but do not offer any medical, clinical, or counsel...