ogflash commited on
Commit
1f9a83e
·
1 Parent(s): 870cc4e

Fix: Create and set permissions for uploads directory in Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -2
Dockerfile CHANGED
@@ -6,7 +6,10 @@ WORKDIR /app
6
 
7
  # Install ffmpeg which is required by pydub
8
  # Use 'apt-get update' and 'apt-get install' for Debian-based images
9
- RUN apt-get update && apt-get install -y ffmpeg
 
 
 
10
 
11
  # Copy the requirements file into the working directory
12
  COPY requirements.txt .
@@ -14,6 +17,16 @@ COPY requirements.txt .
14
  # Install any needed packages specified in requirements.txt
15
  RUN pip install --no-cache-dir -r requirements.txt
16
 
 
 
 
 
 
 
 
 
 
 
17
  # Copy the rest of the application code into the working directory
18
  COPY . .
19
 
@@ -21,5 +34,5 @@ COPY . .
21
  EXPOSE 8000
22
 
23
  # Command to run the application
24
- # Use gunicorn with uvicorn workers for production-ready deployment
25
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
 
6
 
7
  # Install ffmpeg which is required by pydub
8
  # Use 'apt-get update' and 'apt-get install' for Debian-based images
9
+ # Add rm -rf /var/lib/apt/lists/* to clean up apt cache and reduce image size
10
+ RUN apt-get update && \
11
+ apt-get install -y ffmpeg && \
12
+ rm -rf /var/lib/apt/lists/*
13
 
14
  # Copy the requirements file into the working directory
15
  COPY requirements.txt .
 
17
  # Install any needed packages specified in requirements.txt
18
  RUN pip install --no-cache-dir -r requirements.txt
19
 
20
+ # --- ADD THESE LINES TO CREATE AND PERMIT THE UPLOADS DIRECTORY ---
21
+ # Create the uploads directory and set permissions for the user running the app
22
+ # The default user in python:3.11-slim-buster is root, which has full permissions.
23
+ # This makes it explicit and prepares for potential user switching.
24
+ RUN mkdir -p uploads && chmod 777 uploads
25
+ # A more robust (and often safer) approach if you were using a dedicated non-root user:
26
+ # RUN mkdir -p uploads && chown <user>:<group> uploads && chmod 755 uploads
27
+ # For now, 777 is fine to confirm it works.
28
+ # ------------------------------------------------------------------
29
+
30
  # Copy the rest of the application code into the working directory
31
  COPY . .
32
 
 
34
  EXPOSE 8000
35
 
36
  # Command to run the application
37
+ # Use gunicorn with uvicorn workers for production-ready deployment (optional, your current CMD is fine for simple FastAPI)
38
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]