First working example.

This commit is contained in:
gtrefalt 2024-11-25 22:37:04 +01:00
parent 837a3737ce
commit e9e73d21ba
3 changed files with 29 additions and 0 deletions

20
Dockerfile Normal file
View File

@ -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"]

7
main.py Normal file
View File

@ -0,0 +1,7 @@
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
fastapi
uvicorn[standard]