Added docker-compose file
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
|
import asyncio
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, status
|
from fastapi import APIRouter, BackgroundTasks, Depends, status
|
||||||
from fastapi.responses import FileResponse
|
from fastapi.responses import FileResponse
|
||||||
from fastapi_jwt_auth import AuthJWT
|
from fastapi_jwt_auth import AuthJWT
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
@@ -97,7 +98,7 @@ async def delete_sign(id: int, Authorize: AuthJWT = Depends(), session: AsyncSes
|
|||||||
return {"message": "Sign deleted"}
|
return {"message": "Sign deleted"}
|
||||||
|
|
||||||
@router.get("/download/all", status_code=status.HTTP_200_OK)
|
@router.get("/download/all", status_code=status.HTTP_200_OK)
|
||||||
async def download_all(Authorize: AuthJWT = Depends(), session: AsyncSession = Depends(get_session)):
|
async def download_all(background_tasks: BackgroundTasks, Authorize: AuthJWT = Depends(), session: AsyncSession = Depends(get_session)):
|
||||||
Authorize.jwt_required()
|
Authorize.jwt_required()
|
||||||
|
|
||||||
user = Authorize.get_jwt_subject()
|
user = Authorize.get_jwt_subject()
|
||||||
@@ -120,5 +121,12 @@ async def download_all(Authorize: AuthJWT = Depends(), session: AsyncSession = D
|
|||||||
for path in paths:
|
for path in paths:
|
||||||
zip_file.write(f"{settings.DATA_PATH}/{path}", os.path.basename(path))
|
zip_file.write(f"{settings.DATA_PATH}/{path}", os.path.basename(path))
|
||||||
|
|
||||||
# return the zip file and delete it after the request is done
|
background_tasks.add_task(delete_zip_file, zip_path)
|
||||||
return FileResponse(zip_path, media_type="application/zip", filename="signs.zip", delete_after_request=True)
|
# serve the zip file as the response
|
||||||
|
response = FileResponse(zip_path, media_type="application/zip", filename="signs.zip")
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
|
# define a function to delete the zip file
|
||||||
|
async def delete_zip_file(zip_path):
|
||||||
|
os.remove(zip_path)
|
||||||
27
docker-compose.yml
Normal file
27
docker-compose.yml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
version: "3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
backend:
|
||||||
|
build: ./backend
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
volumes:
|
||||||
|
- ./data:/data
|
||||||
|
|
||||||
|
environment:
|
||||||
|
DB_USE_SQLITE: "true"
|
||||||
|
DB_SQLITE_PATH: "/data/sqlite.db"
|
||||||
|
DATA_PATH: "/data/videos"
|
||||||
|
|
||||||
|
JWT_SECRET_KEY: "e8ae5c5d5cd7f0f1bec2303ad04a7c80f09f759d480a7a5faff5a6bbaa4078d0"
|
||||||
|
|
||||||
|
DEFAULT_USER_ENABLED: "true"
|
||||||
|
DEFAULT_USER_EMAIL: "signlanuage@tool.com"
|
||||||
|
DEFAULT_USER_PASSWORD: "SignLanguageTool123!"
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
build: ./frontend
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
environment:
|
||||||
|
REACT_APP_BACKEND_URL: "http://192.168.1.171:8000"
|
||||||
Reference in New Issue
Block a user