From a476ed22df7edaa5eb912a25d3e7733db0e1403f Mon Sep 17 00:00:00 2001 From: Youcef Guichi Date: Sun, 28 Apr 2024 19:48:37 +0200 Subject: [PATCH] feat: setup fastapi server --- .dockerignore | 7 +++++++ .gitignore | 1 + Dockerfile | 11 +++++++++++ docker/Dockerfile | 3 --- requirements.txt | 13 +++++++++++++ server.py | 10 ++++++++++ 6 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 Dockerfile delete mode 100644 docker/Dockerfile create mode 100644 requirements.txt create mode 100644 server.py diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c2d5065 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +# Ignore everything +** + +# But include +!server.py +!requirements.txt + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f5e96db --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +venv \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f6c9afa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM python:3.11.9-slim + +WORKDIR /podbee/ + +RUN apt update && apt install -y curl wget inetutils-ping dnsutils telnet + +COPY . . + +RUN pip install -r requirements.txt + +CMD uvicorn server:app --host 0.0.0.0 --port 80 diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 1a843b9..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM debian:stable-slim - -RUN apt update && apt install -y curl wget inetutils-ping dnsutils telnet diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..1d7bf59 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,13 @@ +annotated-types==0.6.0 +anyio==4.3.0 +click==8.1.7 +exceptiongroup==1.2.1 +fastapi==0.110.2 +h11==0.14.0 +idna==3.7 +pydantic==2.7.1 +pydantic_core==2.18.2 +sniffio==1.3.1 +starlette==0.37.2 +typing_extensions==4.11.0 +uvicorn==0.29.0 diff --git a/server.py b/server.py new file mode 100644 index 0000000..d774233 --- /dev/null +++ b/server.py @@ -0,0 +1,10 @@ +from fastapi import FastAPI +from fastapi.responses import JSONResponse + +app = FastAPI() + + +@app.get("/") +async def hello(): + message = {"message": "Thank you for using PodBee!"} + return JSONResponse(content=message, status_code=200)