Skip to content

Commit ccb0155

Browse files
committed
Add swagger with .yaml & refactor dockerfile
1 parent fa873a9 commit ccb0155

File tree

4 files changed

+376
-4
lines changed

4 files changed

+376
-4
lines changed

Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
FROM python:3.8
1+
FROM python:3.11-slim-buster
2+
23
WORKDIR /app
34

5+
RUN apt-get update \
6+
&& apt-get -y install libpq-dev gcc \
7+
&& pip install psycopg2
8+
49
COPY requirements.txt ./
510

611
RUN pip install -r requirements.txt
@@ -9,4 +14,7 @@ EXPOSE 8080
914

1015
COPY app/ ./
1116

12-
CMD ["sh", "-c", "uvicorn main:app --reload --host 0.0.0.0 --port 8080 & python main_rabbitmq.py"]
17+
RUN mkdir /docs
18+
COPY /docs /docs
19+
20+
CMD ["sh", "-c", "uvicorn main:app --reload --host 0.0.0.0 --port 8080" & python main_rabbitmq.py"]

app/main.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1+
from pathlib import Path
12
from fastapi import FastAPI
23
from database.database import SQLAlchemyClient
34
import logging
45
from controller.calculator_controller import CalculatorController
56
from schemas.schemas import Request as RequestSchema
67
from service.calculator_service import CalculatorService
78
from router import api_router
9+
from swagger_ui import api_doc
10+
#from os import path
811

912
app = FastAPI()
13+
14+
# swagger_config_path = path.join(path.dirname(path.abspath(__file__)), '../docs/endpoints.yaml')
15+
api_doc(app, config_path='../docs/endpoints.yaml', url_prefix='/api/doc', title='API doc')
16+
1017
service = CalculatorService()
1118
controller = CalculatorController(service)
1219

@@ -54,3 +61,12 @@ async def add_new_device_plant(req: Request,
5461
raise e """
5562

5663
app.include_router(api_router)
64+
65+
66+
67+
68+
69+
70+
71+
72+

0 commit comments

Comments
 (0)