Skip to content

Commit 23e2d50

Browse files
committed
initial commit
0 parents  commit 23e2d50

File tree

12 files changed

+89
-0
lines changed

12 files changed

+89
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.vscode
2+
__pycache__
3+
db/*
4+
!db/.gitkeep

api/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM python:3.9
2+
3+
WORKDIR /code
4+
5+
COPY ./requirements.txt /code/requirements.txt
6+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt \
7+
&& rm -rf /code/requirements.txt
8+
9+
COPY ./app /code/app
10+
11+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80", "--reload"]

api/app/__init__.py

Whitespace-only changes.

api/app/main.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from typing import Union
2+
3+
from fastapi import FastAPI
4+
5+
app = FastAPI()
6+
7+
8+
@app.get("/")
9+
def read_root():
10+
return {"Hello": "World"}
11+
12+
13+
@app.get("/items/{item_id}")
14+
def read_item(item_id: int, q: Union[str, None] = None):
15+
return {"item_id": item_id, "q": q}

api/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fastapi
2+
pydantic
3+
uvicorn

db/.gitkeep

Whitespace-only changes.

docker-compose.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: "3"
2+
services:
3+
web:
4+
build:
5+
context: web
6+
ports:
7+
- "8000:80"
8+
environment:
9+
ENVIRONMENT: dev
10+
API_URL: localhost:5000
11+
volumes:
12+
- ./web/app:/code/app
13+
links:
14+
- api
15+
api:
16+
build:
17+
context: api
18+
ports:
19+
- "5000:80"
20+
environment:
21+
ENVIRONMENT: dev
22+
WEB_URL: localhost:8000
23+
volumes:
24+
- ./api/app:/code/app
25+
- ./db:/code/app/db

web/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM python:3.9
2+
3+
WORKDIR /code
4+
5+
COPY ./requirements.txt /code/requirements.txt
6+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt \
7+
&& rm -rf /code/requirements.txt
8+
9+
COPY ./app /code/app
10+
11+
CMD ["gunicorn", "--conf", "app/gunicorn_conf.py", "--bind", "0.0.0.0:80", "app.main:app"]

web/app/__init__.py

Whitespace-only changes.

web/app/gunicorn_conf.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Gunicorn config variables
2+
loglevel = "info"
3+
errorlog = "-" # stderr
4+
accesslog = "-" # stdout
5+
worker_tmp_dir = "/dev/shm"
6+
graceful_timeout = 120
7+
timeout = 120
8+
keepalive = 5
9+
threads = 3
10+
reloase = "True"

0 commit comments

Comments
 (0)