From e9e73d21ba633c365e5e54268655755630395155 Mon Sep 17 00:00:00 2001 From: gtrefalt Date: Mon, 25 Nov 2024 22:37:04 +0100 Subject: [PATCH] First working example. --- Dockerfile | 20 ++++++++++++++++++++ main.py | 7 +++++++ requirements.txt | 2 ++ 3 files changed, 29 insertions(+) create mode 100644 Dockerfile create mode 100644 main.py create mode 100644 requirements.txt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fd56574 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# Use an official Python runtime as a parent image +FROM python:3.11-slim + +# Set the working directory in the container +WORKDIR /app + +# Copy the requirements file to the working directory +COPY requirements.txt . + +# Install the required dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the FastAPI app code to the container +COPY . . + +# Expose the port on which the app will run +EXPOSE 8000 + +# Define the command to run the application using uvicorn +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/main.py b/main.py new file mode 100644 index 0000000..f5961e6 --- /dev/null +++ b/main.py @@ -0,0 +1,7 @@ +from fastapi import FastAPI + +app = FastAPI() + +@app.get("/") +def read_root(): + return {"Hello": "World"} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..364e2ee --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +fastapi +uvicorn[standard]