bibibi12345 commited on
Commit
0c90ba9
·
1 Parent(s): 374c7c5
Files changed (2) hide show
  1. Dockerfile +17 -7
  2. backend/services/video_service.py +1 -1
Dockerfile CHANGED
@@ -1,18 +1,28 @@
1
  # Use an official Python runtime as a parent image
2
  FROM python:3.9-slim
3
 
4
- # Set the working directory in the container
5
- WORKDIR /app
6
 
7
- # Copy the backend requirements file and install dependencies
8
- COPY backend/requirements.txt .
 
 
 
 
 
 
 
 
 
 
9
  RUN pip install --no-cache-dir -r requirements.txt
10
 
11
- # Copy the backend and frontend code into the container
12
- COPY . .
13
 
14
  # Set the working directory to the backend
15
- WORKDIR /app/backend
16
 
17
  # Expose the port the app runs on
18
  EXPOSE 7860
 
1
  # Use an official Python runtime as a parent image
2
  FROM python:3.9-slim
3
 
4
+ # Create a non-root user
5
+ RUN useradd -m -u 1000 user
6
 
7
+ # Switch to the new user
8
+ USER user
9
+
10
+ # Set home to the user's home directory and update PATH
11
+ ENV HOME=/home/user \
12
+ PATH=/home/user/.local/bin:$PATH
13
+
14
+ # Set the working directory
15
+ WORKDIR $HOME/app
16
+
17
+ # Install dependencies
18
+ COPY --chown=user backend/requirements.txt .
19
  RUN pip install --no-cache-dir -r requirements.txt
20
 
21
+ # Copy the application code
22
+ COPY --chown=user . .
23
 
24
  # Set the working directory to the backend
25
+ WORKDIR $HOME/app/backend
26
 
27
  # Expose the port the app runs on
28
  EXPOSE 7860
backend/services/video_service.py CHANGED
@@ -5,9 +5,9 @@ import aiohttp
5
  from typing import Dict, Any
6
 
7
  VIDEO_DIR = "/tmp/generated_videos"
8
- os.makedirs(VIDEO_DIR, exist_ok=True)
9
 
10
  async def save_video(video_data: Dict[str, Any]) -> str:
 
11
  video_filename = f"{uuid.uuid4()}.mp4"
12
  video_path = os.path.join(VIDEO_DIR, video_filename)
13
 
 
5
  from typing import Dict, Any
6
 
7
  VIDEO_DIR = "/tmp/generated_videos"
 
8
 
9
  async def save_video(video_data: Dict[str, Any]) -> str:
10
+ os.makedirs(VIDEO_DIR, exist_ok=True)
11
  video_filename = f"{uuid.uuid4()}.mp4"
12
  video_path = os.path.join(VIDEO_DIR, video_filename)
13