vikarshana commited on
Commit
e3ba8c9
·
verified ·
1 Parent(s): 5964f9b

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +25 -17
Dockerfile CHANGED
@@ -1,29 +1,37 @@
1
- FROM python:3.9-slim
2
 
3
- WORKDIR /app
 
 
 
 
4
 
5
- # Install required system packages
6
- RUN apt-get update && apt-get install -y ffmpeg
 
 
7
 
8
- # Create a non-root user
9
- RUN useradd -m -u 1000 appuser
10
 
11
- # Copy requirements and install Python packages
12
  COPY requirements.txt .
13
- RUN pip install -r requirements.txt
14
 
15
- # Copy the application files
16
  COPY . .
17
 
18
- # Set permissions for all files and directories
19
- RUN find /app -type f -exec chmod 644 {} \; && \
20
- find /app -type d -exec chmod 755 {} \; && \
21
- chmod 644 www.youtube.com_cookies.txt && \
22
- chown -R appuser:appuser /app
23
 
24
- # Switch to non-root user
25
- USER appuser
 
26
 
 
27
  EXPOSE 7860
28
 
29
- CMD ["python", "srv.py"]
 
 
1
+ FROM python:3.12-alpine
2
 
3
+ # Install dependencies, including su-exec
4
+ RUN apk update && apk add --no-cache ffmpeg su-exec
5
+
6
+ # Create appuser and appgroup
7
+ RUN addgroup -g 1000 appgroup && adduser -D -u 1000 -G appgroup appuser
8
 
9
+ # Set environment variables
10
+ ENV PYTHONDONTWRITEBYTECODE=1
11
+ ENV PYTHONUNBUFFERED=1
12
+ ENV PYTHONPATH=/app/tubetube
13
 
14
+ # Set the working directory
15
+ WORKDIR /app
16
 
17
+ # Install Python dependencies
18
  COPY requirements.txt .
19
+ RUN pip install --no-cache-dir -r requirements.txt
20
 
21
+ # Copy the application code
22
  COPY . .
23
 
24
+ # Ensure proper ownership of /config, /data and /temp directories
25
+ RUN mkdir -p /config /data /temp && \
26
+ chown -R appuser:appgroup /config /data /temp && \
27
+ chmod -R 775 /temp
 
28
 
29
+ # Copy start script and make it executable
30
+ COPY start.sh /app/start.sh
31
+ RUN chmod +x /app/start.sh
32
 
33
+ # Expose the application port
34
  EXPOSE 7860
35
 
36
+ # Use the start script as the entrypoint
37
+ ENTRYPOINT ["/app/start.sh"]