add docker files
This commit is contained in:
16
backend/Dockerfile
Normal file
16
backend/Dockerfile
Normal file
@@ -0,0 +1,16 @@
|
||||
FROM python:3.11-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Dependencies installieren
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Source-Code kopieren
|
||||
COPY src/ ./src
|
||||
|
||||
# Port öffnen
|
||||
EXPOSE 8000
|
||||
|
||||
# FastAPI starten (Uvicorn)
|
||||
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
@@ -1,5 +1,6 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
import os
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
@@ -13,4 +14,10 @@ app.add_middleware(
|
||||
|
||||
@app.get("/api/hello")
|
||||
def read_root():
|
||||
return {"message": "Hallo von FastAPI 🎉"}
|
||||
return {"message": "Hallo von FastAPI 🎉"}
|
||||
|
||||
|
||||
@app.get("/api/versions")
|
||||
def read_root():
|
||||
message = os.popen("python --version").read().strip()
|
||||
return {"message": message}
|
||||
Reference in New Issue
Block a user