docker
This commit is contained in:
20
backend/Dockerfile
Normal file
20
backend/Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE=1
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
|
||||
WORKDIR /app/backend
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends ffmpeg \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY backend/requirements.txt ./requirements.txt
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY backend /app/backend
|
||||
COPY storage /app/storage
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
from typing import Dict, List
|
||||
|
||||
from fastapi import FastAPI, File, HTTPException, UploadFile
|
||||
@@ -10,10 +11,15 @@ from app.services.storage import get_upload_path, save_upload
|
||||
from app.services.tasks import task_manager
|
||||
|
||||
|
||||
def get_allowed_origins() -> List[str]:
|
||||
origins = os.getenv("CORS_ORIGINS", "http://localhost:5173,http://localhost:8080")
|
||||
return [origin.strip() for origin in origins.split(",") if origin.strip()]
|
||||
|
||||
|
||||
app = FastAPI(title="VPlatform API", version="0.1.0")
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["http://localhost:5173"],
|
||||
allow_origins=get_allowed_origins(),
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
|
||||
Reference in New Issue
Block a user