python-fastapi-demo-docker GitHub Details, Stars and Alternatives | OpenRepoFinder
aws-samples / repository
python-fastapi-demo-docker
This Python application leverages FastAPI and Pydantic to provide a high-performance API, bundled with PostgreSQL for data persistence, and is completely refactored for containerization with Docker for smooth deployments.
A transparent discovery signal based on current public GitHub metadata.
Recent activity35% weight
100
Community adoption25% weight
31
Maintenance state20% weight
100
License clarity10% weight
100
Project information10% weight
75
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
README preview
FastAPI Book Management Application
This application is a simple, lightweight Book Management API built with FastAPI and SQLAlchemy. It offers CRUD operations to manage a collection of books. Each book has a unique id, a title, an author, and a description. It is designed with a focus on simplicity, flexibility, and performance, and is ready for containerization with Docker.
About
📦 This app has been refactored for containerization, promoting consistent operating environments and seamless deployments using Docker.
🚀 This app uses the FastAPI framework. FastAPI is a high-performance web framework for building APIs with Python 3.6+ that provides built-in support for asynchronous code. It is highly extensible and compatible with REST, OpenAPI, GraphQL, gRPC, and other protocols.
✅ This app uses Pydantic data validation. Pydantic provides a declarative way to define data schemas and models that can be used across different protocols and API styles. The use of Pydantic models also allows FastAPI to automatically generate API documentation, perform data validation, and serialize/deserialize request and response data, making it easier to build and maintain high-performance APIs.
💾 This app leverages SQLAlchemy for data persistence. A comprehensive ORM implementation is included to automate the interaction with the PostgreSQL database. The SQLAlchemy ORM provides a high-level, Pythonic interface to the database, while still allowing for complex, lower-level SQL constructs. This integration of SQLAlchemy with our Docker containerization process ensures the app is fully equipped to handle complex data structures and queries, making it a powerful, ready-to-run, fully containerized app.
🗃️ This app leverages PostgreSQL for data persistence. A comprehensive initialization script is included to automate the setup of the PostgreSQL database. The script creates a database user, database, and the database table. This integration of the script with our Docker containerization process means the app is fully prepared for container-based deployment, complete with its database setup, epitomizing a ready-to-run, fully containerized app.
A Devops pipeline is set of automated processes and tools that the development (Dev) and operations (Ops) teams implement to build, test, and deploy software faster and easier. In this course you will complete DevOps pipeline generally consists of a set of tools which are normally broken down into the following categories: Plan Code Integrate Test Release Deploy Operate This learning path will cover: Git is an open-source and distributed version control system. Github is git repository hosting service used for code sharing, bug tracking, feature request and much more. PyCharm is an integrated development environment (IDE) for python programing language. Flask is a python web framework. HTML is the standard markup language for Web pages. CSS is a style sheet language use to style a HTML document. SQLAlchemy is an open-source SQL toolkit and object-relational mapper which gives full power and flexibility of SQL. Selenium is used to automate web browser interaction. Pytest is unit testing framework that allows users to write test codes. Ngrok allows to expose a web server running on your local machine to the internet. Github Action enables you to include Continues Integration (CI) and continuous deployment (CD) capabilities and many other features directly in your repository. Docker is an open source containerization platform enables developers to package applications into containers. Docker Hub is a cloud-based repository for finding and sharing container images with your team. Kubernetes is an open-source container orchestration for automating deployment, scaling, and management of containerized applications. This course is one stop shop where you will learn web development, continuous integration, continuous deployment, containerization, writing neat and quality code, devops concepts and much more with python programing language. What you’ll learn Learn to build Continuous Integration Continuous Deployment pipeline Build CI CD tool to update docker image after any update Learn to create dockerfile Learn the fundamental concepts of Docker Learn the fundamental concepts of Kubernetes Learn to create Kubernetes YAML files Learn to deploy high availability, fault tolerance, scalable application Learn all the basic and advanced git commands Learn different types of branches like master, developer, feature, release and hotfix branch Learn fundamental concepts of Version Control System Learn to use Github actions for CI CD pipeline Learn to build python flask web application Learn to use SQL Alchemy Lean to create HTML pages using HTML, CSS and bootstrap Are there any course requirements or prerequisites? Git installed Docker installed Kubernetes installed Any IDE Github account Docker hub account Who this course is for: Anyone who wants to Enhance their skills in DevOps domain Developers and IT Pros Instructor User photo Pranjal Srivastava Docker | Kubernetes | AWS | Azure | ML | Linux | Python I am an Instructor, Devops engineer, machine learning enthusiast, cloud expert and passionate developer. I have authored 60+ courses with over 50,000+ students worldwide across 175+ countries on wide array of technologies like containerization, machine learning, Linux, programming languages and cloud computing platforms like Microsoft Azure, Amazon Web Service and IBM Cloud.
Navigate into the project directory and make a copy of the example environment variables file.
cd python-fastapi-demo-docker
cp .env.example .env
The .env file contains the database credentials. You can modify these credentials if necessary.
Quickstart
These steps show how to set up the database and the application using Docker.
In the project root directory, build the Docker images.
docker-compose build
Run the Docker containers.
docker-compose up
At this point, the application should be running at http://localhost:8000/. To stop the application, you can run:
docker-compose down
To restart or rebuild the application, you can run:
docker-compose up --build
Documentation
FastAPI autogenerates an OpenAPI specification, which allows you to test this application directly from an interactive console in your browser. It uses the Pydantic model to validate user input (as shown in the models section of the specification, below). Go to http://0.0.0.0:8000/docs to use the automatic interactive API documentation for this application (provided by Swagger UI) to send requests.
GET /
The root endpoint that returns a welcome greeting.
GET /create_book
This endpoint displays the form for creating a new book.
POST /books
This endpoint creates a new book with the provided title, author, and description. On success, it redirects to the /books endpoint.
GET /books
This endpoint lists all the books in the collection.
GET /books/{book_id}
This endpoint displays the details of a single book specified by the book_id.
GET /books/{book_id}/update
This endpoint displays a form for updating the details of a single book specified by the book_id.
POST /books/{book_id}/update
This endpoint accepts form data and updates the details of the specified book. On success, it redirects to the book detail view of the updated book.
DELETE /books/{book_id}
This endpoint deletes the specified book from the collection.
This project covers the implementation of dockerizing a python flask based credit risk assessment calculator web application integrated with two different deep learning and transfer learning based ML models; using Amazon AWS Elastic Container Registry (ECR), AWS Elastic Container Service (ECS) and deployed into both AWS Fargate Cluster and EC2 Instance/Cluster. Calculating a 3-digit credit score of an individual and the percentage of probability of default of the individual are the outcomes of the 2 ML models deployed. The implementation includes below steps: 1. Creation of a Docker File for the Python Flask Based Credit Risk Assessment Web Application with 2 Deep Learning Models 2. Created a new EC2 Ubuntu Server Instance in AWS and copied the web application project’s directories and files into the AWS Ubuntu Server using SFTP linux commands. 3. Transformation of the Docker File into a Docker Image 4. Creation of a Docker Repository in AWS using AWS ECR Service 5. Authentication the Docker User Login Credentials with AWS using AWS Command Line Interface (CLI) 6. Pushed the Web Application’s Docker Image in to AWS ECR 7. Creation of the Docker Container in the AWS using AWS ECS Service 8. Creation of the Task Definition in the AWS ECS Service linked to the Docker Container 9. Configured the ECS Service Definition, by denoting the replicas of the task definitions to be executed. Enabled Load Balancer feature to manage the incoming load of the web application’s requests and traffic into the AWS Cluster. 10. Configured the AWS Fargate Cluster to execute the service and the tasks; and deployed the docker based web application into AWS Fargate Cluster. 11. Alternately; created and configured the AWS EC2 Instance/Cluster. Created Identity and Access Management (IAM) user with role and policies. Executed the ECS tasks; and deployed the docker based web application into AWS EC2 Instance. Tools & Technologies: Python, Flask, HTML, AWS, EC2, Ubuntu Server, Linux Commands, Command Line Interface (CLI), Docker, ECR, ECS, Fargate, IAM
** This assignment will combine a few things that you have learned in this class and will require a little learning on your own. Do your best and be creative. If you need help ask sooner rather than later in slack. Myself and your classmates are here to help and do not wait to the last minute to do this assignment. ** You may work in two person teams, if you plan to do so please email me to let me know who you are working with. You may NOT work in multiple teams. ** You may use python, JAVA or node.js (javascript) for this assignment. ** I have listed some tutorials below, but you may need to google some on your own. What You Will Do: You will create a RESTful web service that runs in a docker container. Your web service will contain two GET routes: One that displays a collection of records One that displays a single record that the corresponds to an ID Example: If I created two routes, /customers and /customers/35 (note, that 35 is the ID of a given customer in my database) The data returned from your web service routes must be in JSON or XML form. Note, if you would like to load your results in a web page you are welcome to do so, you just need a way to display the data your routes return in a web browser. You will create a hardcoded JSON file based database as the backing datastore for your web service routes. Note, if you are comfortable using a SQL or NO-SQL database as your datastore you may do so but it is not required. Also note, your data model is something you make up. Meaning you can store a collection of cars, customers, food items, restaurants, video games, sports teams etc. Be creative :) This is similar to what the presenter did in the GraphQL video we watched in our last class. He used a JSON file as a database for his demo. You will have to present your work to the class, with a live demo or video you recorded of you running your web service from own computer. This is not optional! Tutorials: Docker What is docker: https://www.youtube.com/watch?v=dz5_lsWlfTU Installing Docker: Windows - https://www.youtube.com/watch?v=wCTTHhehJbU Docker Tutorial (Step by Step) - https://www.youtube.com/watch?v=Vyp5_F42NGs https://blog.talpor.com/2015/01/docker-beginners-tutorial/ https://docs.docker.com/engine/getstarted/ https://hackr.io/tutorials/learn-docker Python RESTful services using Flask: https://code.tutsplus.com/tutorials/building-restful-apis-with-flask-diy--cms-26625 https://impythonist.wordpress.com/2015/07/12/build-an-api-under-30-lines-of-code-with-python-and-flask/ Node + Express REST API Example https://closebrace.com/tutorials/2017-03-02/creating-a-simple-restful-web-app-with-nodejs-express-and-mongodb Node Simple RESTful API (shows using json file as DB) https://www.tutorialspoint.com/nodejs/nodejs_restful_api.htm Dockerize your Flask App https://www.smartfile.com/blog/dockerizing-a-python-flask-application/ http://containertutorials.com/docker-compose/flask-simple-app.html Docker + Spring Boot (JAVA) https://spring.io/guides/gs/spring-boot-docker/ To Submit The Assignment (Read Carefully): ** Please follow all instructions as not following them will lead to loss of points. Create a github account. Create public github repository and all all of your source code for this assignment to the repository. (See the “getting started with github” document in the “Course Documents > Tutorials & Cheat Sheets” folder for help) Make sure to add a README file to the root of your repository that describes what your web service does. Create a presentation powerpoint slide deck that contains 2 slides: A title slides that contains your name(s) and the name of your web service project A slide that talks a little about your data model Submit the following to the “Submit Assignment” thread in RESTful Web Service Implementation + Docker discussion board. The powerpoint slide file. Link to your public github repository that contains all of the source code including your JSON database file. Note, if you worked with classmate for this assignment...if you did please state the person you worked with.
This is a social network project developed using Django. The application provides a wide range of functionality, including managing users, chats, posts, notifications, profiles and much more. Mood project for working in Docker containers.
This is a lightweight Flask web application that runs inside a Docker container and exposes real-time CPU, memory, disk, and network usage metrics (with a 5-minute history) along with threshold-based alerts.