ishworrsubedii commited on
Commit
5b1e9ea
·
1 Parent(s): dc99ae6

update: dockerfile ffmpeg permission

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -18
Dockerfile CHANGED
@@ -18,23 +18,27 @@ RUN apt-get update && apt-get install -y \
18
  imagemagick \
19
  && rm -rf /var/lib/apt/lists/*
20
 
21
- # Create directories with proper permissions
22
- WORKDIR /app
23
- RUN mkdir -p /app/resources/{temp_video,audio,fonts,intro} && \
24
- mkdir -p /tmp/moviepy && \
25
- mkdir -p /tmp/audio_temp && \
26
- chmod -R 777 /app/resources && \
27
- chmod -R 777 /tmp/moviepy && \
28
- chmod -R 777 /tmp/audio_temp && \
29
- chmod -R 777 /tmp
30
 
31
- # Copy and install requirements
32
- COPY requirements.txt .
33
- RUN pip3 install -r requirements.txt
34
 
35
  # Copy application code
36
  COPY . .
37
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  # Configure ImageMagick with more permissive policy
39
  RUN mv /etc/ImageMagick-6/policy.xml /etc/ImageMagick-6/policy.xml.bak || true
40
  RUN echo '<policymap> \
@@ -48,13 +52,8 @@ RUN echo '<policymap> \
48
  <policy domain="path" rights="read|write" pattern="/tmp/*"/> \
49
  </policymap>' > /etc/ImageMagick-6/policy.xml
50
 
51
- # Set proper permissions for the entire application
52
- RUN chown -R nobody:nogroup /app && \
53
- chmod -R 755 /app && \
54
- chmod -R 777 /tmp
55
-
56
  # Switch to non-root user
57
- USER nobody
58
 
59
  EXPOSE 7860
60
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
18
  imagemagick \
19
  && rm -rf /var/lib/apt/lists/*
20
 
21
+ # Create a non-root user
22
+ RUN useradd -m appuser
 
 
 
 
 
 
 
23
 
24
+ # Set working directory
25
+ WORKDIR /app
 
26
 
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
37
+ RUN pip3 install --user -r requirements.txt
38
+
39
+ # Update PATH for user's pip packages
40
+ ENV PATH="/home/appuser/.local/bin:${PATH}"
41
+
42
  # Configure ImageMagick with more permissive policy
43
  RUN mv /etc/ImageMagick-6/policy.xml /etc/ImageMagick-6/policy.xml.bak || true
44
  RUN echo '<policymap> \
 
52
  <policy domain="path" rights="read|write" pattern="/tmp/*"/> \
53
  </policymap>' > /etc/ImageMagick-6/policy.xml
54
 
 
 
 
 
 
55
  # Switch to non-root user
56
+ USER appuser
57
 
58
  EXPOSE 7860
59
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]