ishworrsubedii commited on
Commit
19fd313
·
1 Parent(s): b110fef

update: temp dir path

Browse files
Files changed (2) hide show
  1. Dockerfile +8 -2
  2. app.py +6 -3
Dockerfile CHANGED
@@ -27,14 +27,20 @@ WORKDIR /app
27
  # Copy application code
28
  COPY . .
29
 
 
 
 
30
  # Set ownership and permissions
31
  RUN chown -R appuser:appuser /app && \
32
  chown -R appuser:appuser /tmp && \
33
  chmod -R 755 /app && \
34
  chmod -R 777 /tmp
35
 
36
- # Install Python dependencies globally
37
- RUN pip3 install -r requirements.txt
 
 
 
38
 
39
  # Configure ImageMagick with a permissive policy
40
  RUN mv /etc/ImageMagick-6/policy.xml /etc/ImageMagick-6/policy.xml.bak || true
 
27
  # Copy application code
28
  COPY . .
29
 
30
+ # Install Python dependencies globally
31
+ RUN pip3 install -r requirements.txt
32
+
33
  # Set ownership and permissions
34
  RUN chown -R appuser:appuser /app && \
35
  chown -R appuser:appuser /tmp && \
36
  chmod -R 755 /app && \
37
  chmod -R 777 /tmp
38
 
39
+ # Create required directories and set permissions
40
+ RUN mkdir -p /app/resources/{audio,fonts,intro,temp_video} && \
41
+ chown -R appuser:appuser /app/resources && \
42
+ chmod -R 755 /app/resources && \
43
+ chmod -R 777 /app/resources/temp_video
44
 
45
  # Configure ImageMagick with a permissive policy
46
  RUN mv /etc/ImageMagick-6/policy.xml /etc/ImageMagick-6/policy.xml.bak || true
app.py CHANGED
@@ -14,8 +14,12 @@ supabase_key = os.getenv('SUPABASE_KEY')
14
  supabase = create_client(supabase_url, supabase_key)
15
  app = FastAPI()
16
 
17
- RESOURCES_DIR = "resources"
 
18
  os.makedirs(RESOURCES_DIR, exist_ok=True)
 
 
 
19
 
20
  os.environ['MOVIEPY_TEMP_DIR'] = '/tmp/moviepy'
21
 
@@ -87,8 +91,7 @@ async def create_video(request: VideoGenerator):
87
  status_code=400)
88
 
89
  intro_path = f"{RESOURCES_DIR}/intro/{request.intro_video_path}"
90
- output_path = f"{RESOURCES_DIR}/temp_video/video_{os.urandom(8).hex()}.mp4"
91
- font_path = f"{RESOURCES_DIR}/fonts/{request.font_path}"
92
  audio_path = f"{RESOURCES_DIR}/audio/{request.background_audio_path}"
93
 
94
  video_creator = VideoCreator(
 
14
  supabase = create_client(supabase_url, supabase_key)
15
  app = FastAPI()
16
 
17
+ RESOURCES_DIR = "/aap/resources"
18
+
19
  os.makedirs(RESOURCES_DIR, exist_ok=True)
20
+ TEMP_VIDEO_DIR = f"{RESOURCES_DIR}/temp_video"
21
+
22
+ os.makedirs(f"{RESOURCES_DIR}/temp_video", exist_ok=True)
23
 
24
  os.environ['MOVIEPY_TEMP_DIR'] = '/tmp/moviepy'
25
 
 
91
  status_code=400)
92
 
93
  intro_path = f"{RESOURCES_DIR}/intro/{request.intro_video_path}"
94
+ output_path = f"{TEMP_VIDEO_DIR}/video_{os.urandom(8).hex()}.mp4" font_path = f"{RESOURCES_DIR}/fonts/{request.font_path}"
 
95
  audio_path = f"{RESOURCES_DIR}/audio/{request.background_audio_path}"
96
 
97
  video_creator = VideoCreator(