Maouu commited on
Commit
fb8d4cf
·
verified ·
1 Parent(s): 6e2d4b0

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -21
Dockerfile CHANGED
@@ -1,49 +1,43 @@
1
  FROM python:3.9-slim
2
 
3
- # ----------- System dependencies -----------
4
  RUN apt-get update && apt-get install -y --no-install-recommends \
5
  build-essential gcc libffi-dev libpq-dev curl gnupg ca-certificates && \
6
  apt-get clean && rm -rf /var/lib/apt/lists/*
7
 
8
- # ----------- Install Node.js 18.x -----------
9
  RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
10
  apt-get install -y nodejs && \
11
  node -v && npm -v
12
 
13
- # ----------- App setup -----------
14
  WORKDIR /app
15
 
16
- # Python deps
17
  COPY requirements.txt .
18
  RUN pip install --no-cache-dir --upgrade pip && \
19
  pip install --no-cache-dir -r requirements.txt
20
 
21
- # Node deps
22
  COPY test.js ./
23
  RUN npm install youtube-po-token-generator
24
 
25
- # App code
26
- COPY . .
27
 
28
- # Create cache dir for pytubefix with proper permissions
29
- RUN mkdir -p /app/cache && \
30
- chown 1000:1000 /app/cache && \
31
- chmod 755 /app/cache
32
 
33
- # Create logs file with proper permissions
34
- RUN touch logs.json && \
35
- chown 1000:1000 logs.json && \
36
- chmod 664 logs.json
37
-
38
- # Create non-root user
39
  RUN useradd -m -u 1000 user
40
  USER user
41
 
42
- # Ensure pip binaries are available
 
43
  ENV PATH="/home/user/.local/bin:$PATH"
44
 
45
- # Expose the app port
46
  EXPOSE 7860
47
 
48
- # Start the FastAPI app
49
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "2"]
 
1
  FROM python:3.9-slim
2
 
3
+ # System dependencies
4
  RUN apt-get update && apt-get install -y --no-install-recommends \
5
  build-essential gcc libffi-dev libpq-dev curl gnupg ca-certificates && \
6
  apt-get clean && rm -rf /var/lib/apt/lists/*
7
 
8
+ # Install Node.js (v18)
9
  RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
10
  apt-get install -y nodejs && \
11
  node -v && npm -v
12
 
13
+ # Set workdir
14
  WORKDIR /app
15
 
16
+ # Copy requirements and install Python deps
17
  COPY requirements.txt .
18
  RUN pip install --no-cache-dir --upgrade pip && \
19
  pip install --no-cache-dir -r requirements.txt
20
 
21
+ # Copy Node.js files and install npm deps
22
  COPY test.js ./
23
  RUN npm install youtube-po-token-generator
24
 
25
+ # Create cache dir for pytubefix/pytube with correct permissions
26
+ RUN mkdir -p /app/cache && chown 1000:1000 /app/cache && chmod 755 /app/cache
27
 
28
+ # Create logs.json with correct permissions
29
+ RUN touch logs.json && chown 1000:1000 logs.json && chmod 664 logs.json
 
 
30
 
31
+ # Create and switch to non-root user
 
 
 
 
 
32
  RUN useradd -m -u 1000 user
33
  USER user
34
 
35
+ # Set environment variables
36
+ ENV PYTUBE_CACHE_DIR=/app/cache
37
  ENV PATH="/home/user/.local/bin:$PATH"
38
 
39
+ # Expose port
40
  EXPOSE 7860
41
 
42
+ # Start app
43
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "2"]