First working example.
This commit is contained in:
parent
837a3737ce
commit
e9e73d21ba
|
|
@ -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"]
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
from fastapi import FastAPI
|
||||||
|
|
||||||
|
app = FastAPI()
|
||||||
|
|
||||||
|
@app.get("/")
|
||||||
|
def read_root():
|
||||||
|
return {"Hello": "World"}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
fastapi
|
||||||
|
uvicorn[standard]
|
||||||
Loading…
Reference in New Issue