ishworrsubedii commited on
Commit
371c310
·
1 Parent(s): a507a7f

update: docker image magic

Browse files
Files changed (3) hide show
  1. Dockerfile +13 -8
  2. app.py +9 -0
  3. src/components/vidgen.py +5 -4
Dockerfile CHANGED
@@ -1,23 +1,28 @@
 
1
  FROM python:3.9-slim
2
 
 
3
  WORKDIR /app
4
 
5
- # Give write permissions to the app directory
6
- RUN chmod 777 /app
7
-
8
  # Install dependencies including ffmpeg and imagemagick
9
- RUN apt-get update && apt-get install -y \
10
  ffmpeg \
11
- imagemagick libmagickwand-dev --no-install-recommends \
12
- && pecl install imagick \
13
- && docker-php-ext-enable imagick \
14
  && rm -rf /var/lib/apt/lists/*
15
 
 
16
  COPY requirements.txt ./
17
 
 
18
  RUN pip install --no-cache-dir -r requirements.txt
19
 
20
- # Copy all files from the current directory to the container
21
  COPY . .
22
 
 
 
 
 
 
23
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use the official Python 3.9 slim image as the base
2
  FROM python:3.9-slim
3
 
4
+ # Set the working directory inside the container
5
  WORKDIR /app
6
 
 
 
 
7
  # Install dependencies including ffmpeg and imagemagick
8
+ RUN apt-get update && apt-get install -y --no-install-recommends \
9
  ffmpeg \
10
+ imagemagick \
11
+ libmagickwand-dev \
 
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
+ # Copy the requirements file into the container
15
  COPY requirements.txt ./
16
 
17
+ # Install Python dependencies from the requirements file
18
  RUN pip install --no-cache-dir -r requirements.txt
19
 
20
+ # Copy all application files into the container
21
  COPY . .
22
 
23
+ # Set permissions and run as a non-root user for security
24
+ RUN chown -R nobody:nogroup /app && chmod 755 /app
25
+ USER nobody
26
+
27
+ # Command to run the application using Uvicorn
28
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
app.py CHANGED
@@ -2,6 +2,7 @@ import os
2
  import tempfile
3
 
4
  from fastapi import FastAPI, File, UploadFile
 
5
  from starlette.responses import JSONResponse
6
  from supabase import create_client
7
 
@@ -29,6 +30,14 @@ def upload_to_supabase(video_path, bucket_name="JewelmirrorVideoGeneration"):
29
  return None
30
 
31
 
 
 
 
 
 
 
 
 
32
  @app.post("/create-video/")
33
  async def create_video(
34
  necklace_image: UploadFile = File(...),
 
2
  import tempfile
3
 
4
  from fastapi import FastAPI, File, UploadFile
5
+ from pydantic import BaseModel
6
  from starlette.responses import JSONResponse
7
  from supabase import create_client
8
 
 
30
  return None
31
 
32
 
33
+ class VideoGenerator(BaseModel):
34
+ necklace_image: str
35
+ necklace_try_on_output_images: list[str]
36
+ clothing_output_images: list[str]
37
+ makeup_output_images: list[str]
38
+ store_name: str
39
+
40
+
41
  @app.post("/create-video/")
42
  async def create_video(
43
  necklace_image: UploadFile = File(...),
src/components/vidgen.py CHANGED
@@ -14,12 +14,13 @@ from moviepy.video.io.VideoFileClip import VideoFileClip
14
 
15
 
16
  class VideoCreator:
17
- def __init__(self, intro_video_path, necklace_image, nto_image1, nto_cto_1, nto_cto_2, makeup_1, font_path,
 
18
  output_path, audio_path):
19
  self.intro_video_path = intro_video_path
20
- self.nto_images_dir = [nto_image1]
21
- self.nto_cto_images_dir = [nto_cto_1, nto_cto_2]
22
- self.makeup_images_dir = [makeup_1]
23
  self.output_video_path = output_path
24
  self.font_path = font_path
25
  self.necklace_image = necklace_image
 
14
 
15
 
16
  class VideoCreator:
17
+ def __init__(self, intro_video_path, necklace_image, nto_outputs: list, nto_cto_outputs: list, makeup_outputs: list,
18
+ font_path,
19
  output_path, audio_path):
20
  self.intro_video_path = intro_video_path
21
+ self.nto_images_dir = nto_outputs
22
+ self.nto_cto_images_dir = nto_cto_outputs
23
+ self.makeup_images_dir = [makeup_outputs]
24
  self.output_video_path = output_path
25
  self.font_path = font_path
26
  self.necklace_image = necklace_image