Skip to content

Commit f646d42

Browse files
committed
Add detailed README with diagram and usage
1 parent 4e91f07 commit f646d42

File tree

4 files changed

+179
-2
lines changed

4 files changed

+179
-2
lines changed

README.md

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,95 @@
1-
## FASTAPI-DOCKER-GITHUB-ACTIONS-LAB
1+
## FASTAPI-DOCKER-GITHUB-ACTIONS
22

33
![example workflow](https://github.com/san99tiago/fastapi-docker-github-actions/actions/workflows/ci.yml/badge.svg)
44

5-
TODO: Add detailed README.md with diagram/explanation of the repo.
5+
<img src="assets/fastapi-docker-github-actions.png" width=90%> <br>
6+
7+
## Overview 🔮
8+
9+
Welcome to the FastAPI-Docker-GitHub-Actions Lab! This repository serves as an educational example of a CI/CD project that demonstrates the usage of GitHub Actions for deploying a simple FastAPI server. Key components include:
10+
11+
- Source Code: [Python Runtime](https://www.python.org)
12+
- Dependency Management: [Python Poetry](https://python-poetry.org)
13+
- Web Framework: [FastAPI](https://fastapi.tiangolo.com)
14+
- Containerization Tools: [Docker](https://www.docker.com) and [Docker-Compose](https://docs.docker.com/compose/)
15+
- Testing: [PyTest Framework](https://docs.pytest.org/) and [Coverage](https://coverage.readthedocs.io/en/latest/)
16+
- Artifact Repository: [DockerHub](https://hub.docker.com)
17+
- Continuous Integration/Continuous Delivery (CI/CD): [GitHub Actions](https://github.com/features/actions)
18+
19+
## Usage 👻
20+
21+
The core idea is to have a CI/CD pipeline that illustrates the automation with Continuous Integration, however, you can follow these steps to configure/run the project locally:
22+
23+
### Clone the repository
24+
25+
Begin by cloning this repository to your local machine:
26+
27+
```bash
28+
git clone https://github.com/san99tiago/fastapi-docker-github-actions
29+
cd fastapi-docker-github-actions
30+
```
31+
32+
### Configure Python Dependencies with Poetry
33+
34+
To manage Python dependencies and create a virtual environment, install [Poetry](https://python-poetry.org) following the instructions for your preferred installation method:
35+
36+
- https://python-poetry.org/docs/
37+
38+
Once Poetry is installed, execute the following commands for its setup:
39+
40+
```bash
41+
poetry shell
42+
poetry install
43+
```
44+
45+
### Run the Server Locally with Uvicorn
46+
47+
To run the FastAPI server with Uvicorn, use the following command:
48+
49+
```bash
50+
poe fastapi-local
51+
```
52+
53+
### Run the Server Locally with Docker-Compose
54+
55+
For an easy way to run the FastAPI server as a Docker container using Docker-Compose, use the following commands:
56+
57+
```bash
58+
# Start the service
59+
poe fastapi-docker-up
60+
61+
# Stop the service
62+
poe fastapi-docker-down
63+
```
64+
65+
### Validate the Server
66+
67+
After running the server using the previous commands, open your preferred tool for making API requests and try the following REST-API endpoints:
68+
69+
- `[GET]`: http://127.0.0.1:8000/
70+
- `[GET]`: http://127.0.0.1:8000/status
71+
72+
## Special thanks
73+
74+
A big thank you to all the dedicated contributors who have made the open-source projects used in this repository possible. <br>
75+
76+
## Author :musical_keyboard:
77+
78+
### Santiago Garcia Arango
79+
80+
This repository's content is inspired by multiple online resources. Please feel free to use it as a guide for your future projects.! <br>
81+
82+
<table border="1">
83+
<tr>
84+
<td>
85+
<p align="center"><img src="assets/SantiagoGarciaArango_Python.png" width=70%></p>
86+
</td>
87+
<td>
88+
<p align="center">As a Curious DevOps Engineer, I am deeply passionate about implementing cutting-edge cloud-based solutions on AWS.<br> I firmly believe that today's greatest challenges must be solved by the expertise of individuals who are truly passionate about their work.
89+
</p>
90+
</td>
91+
</tr>
92+
</table>
693

794
## LICENSE
895

117 KB
Loading
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<mxfile host="app.diagrams.net" modified="2023-09-09T03:29:27.437Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36" etag="Ao4b1N1JN3lKicuJOan-" version="21.7.4" type="device">
2+
<diagram name="Page-1" id="8FTfbC2rcARjfSEzrA1y">
3+
<mxGraphModel dx="1871" dy="536" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
4+
<root>
5+
<mxCell id="0" />
6+
<mxCell id="1" parent="0" />
7+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-1" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=14;fontStyle=1" vertex="1" parent="1">
8+
<mxGeometry x="40" y="87" width="620" height="230" as="geometry" />
9+
</mxCell>
10+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-4" value="" style="shape=image;html=1;verticalAlign=top;verticalLabelPosition=bottom;labelBackgroundColor=#ffffff;imageAspect=0;aspect=fixed;image=https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-social-github-128.png;fontSize=14;fontStyle=1" vertex="1" parent="1">
11+
<mxGeometry x="70" y="217" width="70" height="70" as="geometry" />
12+
</mxCell>
13+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-8" value="Developers" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;strokeColor=#232F3E;fillColor=#ffffff;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;fontSize=14;fontStyle=1;aspect=fixed;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.users;" vertex="1" parent="1">
14+
<mxGeometry x="-60" y="118.13" width="73" height="73" as="geometry" />
15+
</mxCell>
16+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-9" value="" style="image;sketch=0;aspect=fixed;html=1;points=[];align=center;fontSize=14;image=img/lib/mscae/Docker.svg;fontStyle=1" vertex="1" parent="1">
17+
<mxGeometry x="480.47" y="227" width="92.07" height="75.5" as="geometry" />
18+
</mxCell>
19+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-12" value="" style="shape=image;verticalLabelPosition=bottom;labelBackgroundColor=default;verticalAlign=top;aspect=fixed;imageAspect=0;image=https://camo.githubusercontent.com/86d9ca3437f5034da052cf0fd398299292aab0e4479b58c20f2fc37dd8ccbe05/68747470733a2f2f666173746170692e7469616e676f6c6f2e636f6d2f696d672f6c6f676f2d6d617267696e2f6c6f676f2d7465616c2e706e67;fontSize=14;fontStyle=1" vertex="1" parent="1">
20+
<mxGeometry x="465.94000000000005" y="167" width="194.06" height="70" as="geometry" />
21+
</mxCell>
22+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-37" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;fillColor=#60a917;strokeColor=#2D7600;shape=flexArrow;" edge="1" parent="1" source="qcpOVHYHYP0Mq-8yIyMg-17" target="qcpOVHYHYP0Mq-8yIyMg-21">
23+
<mxGeometry relative="1" as="geometry" />
24+
</mxCell>
25+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-17" value="" style="shape=image;verticalLabelPosition=bottom;labelBackgroundColor=default;verticalAlign=top;aspect=fixed;imageAspect=0;image=https://avatars.githubusercontent.com/u/44036562?s=280&amp;v=4;fontSize=14;fontStyle=1" vertex="1" parent="1">
26+
<mxGeometry x="63" y="102" width="80" height="80" as="geometry" />
27+
</mxCell>
28+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-26" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;shape=flexArrow;fillColor=#60a917;strokeColor=#2D7600;" edge="1" parent="1" source="qcpOVHYHYP0Mq-8yIyMg-21" target="qcpOVHYHYP0Mq-8yIyMg-22">
29+
<mxGeometry relative="1" as="geometry" />
30+
</mxCell>
31+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-21" value="Check Coding Standards" style="rounded=1;whiteSpace=wrap;html=1;fontSize=14;fontStyle=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
32+
<mxGeometry x="200" y="102" width="105" height="80" as="geometry" />
33+
</mxCell>
34+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-22" value="Run Tests" style="rounded=1;whiteSpace=wrap;html=1;fontSize=14;fontStyle=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
35+
<mxGeometry x="360" y="102" width="105" height="80" as="geometry" />
36+
</mxCell>
37+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-32" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;shape=flexArrow;fillColor=#60a917;strokeColor=#2D7600;" edge="1" parent="1" source="qcpOVHYHYP0Mq-8yIyMg-23" target="qcpOVHYHYP0Mq-8yIyMg-31">
38+
<mxGeometry relative="1" as="geometry" />
39+
</mxCell>
40+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-23" value="Build &amp;amp; Push to DockerHub" style="rounded=1;whiteSpace=wrap;html=1;fontSize=14;fontStyle=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
41+
<mxGeometry x="510.47" y="102" width="105" height="80" as="geometry" />
42+
</mxCell>
43+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-35" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;shape=flexArrow;fillColor=#60a917;strokeColor=#2D7600;" edge="1" parent="1" target="qcpOVHYHYP0Mq-8yIyMg-4">
44+
<mxGeometry relative="1" as="geometry">
45+
<mxPoint y="252" as="sourcePoint" />
46+
</mxGeometry>
47+
</mxCell>
48+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-24" value="" style="shape=image;verticalLabelPosition=bottom;labelBackgroundColor=default;verticalAlign=top;aspect=fixed;imageAspect=0;image=https://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Visual_Studio_Code_1.35_icon.svg/768px-Visual_Studio_Code_1.35_icon.svg.png;" vertex="1" parent="1">
49+
<mxGeometry x="-80" y="217" width="71" height="71" as="geometry" />
50+
</mxCell>
51+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-28" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;shape=flexArrow;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;fillColor=#60a917;strokeColor=#2D7600;" edge="1" parent="1" source="qcpOVHYHYP0Mq-8yIyMg-22" target="qcpOVHYHYP0Mq-8yIyMg-23">
52+
<mxGeometry relative="1" as="geometry">
53+
<mxPoint x="287" y="152" as="sourcePoint" />
54+
<mxPoint x="350" y="152" as="targetPoint" />
55+
</mxGeometry>
56+
</mxCell>
57+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-29" value="" style="shape=image;verticalLabelPosition=bottom;labelBackgroundColor=default;verticalAlign=top;aspect=fixed;imageAspect=0;image=https://upload.wikimedia.org/wikipedia/commons/thumb/c/c3/Python-logo-notext.svg/701px-Python-logo-notext.svg.png;" vertex="1" parent="1">
58+
<mxGeometry x="580.47" y="224.75" width="73.03" height="80" as="geometry" />
59+
</mxCell>
60+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-30" value="" style="shape=image;verticalLabelPosition=bottom;labelBackgroundColor=default;verticalAlign=top;aspect=fixed;imageAspect=0;image=https://assets-global.website-files.com/6064b31ff49a2d31e0493af1/63a2fd04f7078f9ab787025f_dockerhub.svg;" vertex="1" parent="1">
61+
<mxGeometry x="695" y="169.5" width="95" height="95" as="geometry" />
62+
</mxCell>
63+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-31" value="DockerHub" style="rounded=1;whiteSpace=wrap;html=1;fontSize=16;fontStyle=1;fillColor=#1ba1e2;fontColor=#ffffff;strokeColor=#006EAF;" vertex="1" parent="1">
64+
<mxGeometry x="690" y="102" width="105" height="80" as="geometry" />
65+
</mxCell>
66+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-36" value="GitHub Actions" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontStyle=1" vertex="1" parent="1">
67+
<mxGeometry x="58.75" y="187" width="88.5" height="30" as="geometry" />
68+
</mxCell>
69+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-39" value="CI/CD&amp;nbsp; san99tiago/fastapi-docker-github-actions" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;fontStyle=1;fontSize=24;" vertex="1" parent="1">
70+
<mxGeometry x="65" y="40" width="570" height="40" as="geometry" />
71+
</mxCell>
72+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-40" value="" style="shape=image;verticalLabelPosition=bottom;labelBackgroundColor=default;verticalAlign=top;aspect=fixed;imageAspect=0;image=https://upload.wikimedia.org/wikipedia/commons/thumb/b/ba/Pytest_logo.svg/2048px-Pytest_logo.svg.png;clipPath=inset(8% 31% 49% 30.67%);" vertex="1" parent="1">
73+
<mxGeometry x="419.81" y="200" width="46.13" height="51.75" as="geometry" />
74+
</mxCell>
75+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-42" value="" style="shape=image;verticalLabelPosition=bottom;labelBackgroundColor=default;verticalAlign=top;aspect=fixed;imageAspect=0;image=https://johnfraney.ca/blog/images/poetry.png;" vertex="1" parent="1">
76+
<mxGeometry x="194.9" y="190.5" width="115.2" height="48" as="geometry" />
77+
</mxCell>
78+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-49" value="" style="shape=image;imageAspect=0;aspect=fixed;verticalLabelPosition=bottom;verticalAlign=top;image=https://pypi-camo.global.ssl.fastly.net/d3a1a77162e3cd8c3d2089f27899b6eee71af013/68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f7073662f626c61636b2f6d61696e2f646f63732f5f7374617469632f6c6f676f322d726561646d652e706e67;" vertex="1" parent="1">
79+
<mxGeometry x="137.81" y="232.75" width="229.38" height="84.25" as="geometry" />
80+
</mxCell>
81+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-50" value="" style="shape=image;verticalLabelPosition=bottom;labelBackgroundColor=default;verticalAlign=top;aspect=fixed;imageAspect=0;image=https://coverage.readthedocs.io/en/latest/_static/sleepy-snake-circle-150.png;" vertex="1" parent="1">
82+
<mxGeometry x="355.99" y="238.5" width="62.88" height="62.88" as="geometry" />
83+
</mxCell>
84+
<mxCell id="qcpOVHYHYP0Mq-8yIyMg-51" value="" style="shape=image;verticalLabelPosition=bottom;labelBackgroundColor=default;verticalAlign=top;aspect=fixed;imageAspect=0;image=https://upload.wikimedia.org/wikipedia/commons/thumb/b/ba/Pytest_logo.svg/2048px-Pytest_logo.svg.png;clipPath=inset(55.67% 10.67% 13% 6%);" vertex="1" parent="1">
85+
<mxGeometry x="347.08" y="203.5" width="71.79" height="27" as="geometry" />
86+
</mxCell>
87+
</root>
88+
</mxGraphModel>
89+
</diagram>
90+
</mxfile>
409 KB
Loading

0 commit comments

Comments
 (0)