Maouu commited on
Commit
2180488
·
verified ·
1 Parent(s): b784f9d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -9
Dockerfile CHANGED
@@ -1,31 +1,41 @@
1
  FROM python:3.9-slim
2
 
 
3
  RUN apt-get update && apt-get install -y --no-install-recommends \
4
  build-essential gcc libffi-dev libpq-dev curl gnupg ca-certificates && \
5
  apt-get clean && rm -rf /var/lib/apt/lists/*
6
 
 
7
  RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
8
  apt-get install -y nodejs && \
 
9
  node -v && npm -v
10
 
 
11
  WORKDIR /app
12
 
 
13
  COPY requirements.txt .
14
- RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -r requirements.txt
 
15
 
16
- COPY app.py ./ # Make sure your FastAPI app file is named app.py
 
17
  COPY test.js ./
18
- RUN npm install youtube-po-token-generator
19
 
20
- RUN mkdir -p /app/cache && chown 1000:1000 /app/cache && chmod 755 /app/cache
21
- RUN touch logs.json && chown 1000:1000 logs.json && chmod 664 logs.json
22
 
23
- RUN useradd -m -u 1000 user
24
- USER user
 
 
25
 
26
- ENV PYTUBE_CACHE_DIR=/app/cache
27
- ENV PATH="/home/user/.local/bin:$PATH"
28
 
 
29
  EXPOSE 7860
30
 
 
31
  CMD ["uvicorn", "app: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 --------------------
9
  RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
10
  apt-get install -y nodejs && \
11
+ npm install -g npm && \
12
  node -v && npm -v
13
 
14
+ # -------------------- Set Work Directory --------------------
15
  WORKDIR /app
16
 
17
+ # -------------------- Python Dependencies --------------------
18
  COPY requirements.txt .
19
+ RUN pip install --no-cache-dir --upgrade pip && \
20
+ pip install --no-cache-dir -r requirements.txt
21
 
22
+ # -------------------- Copy Source Code --------------------
23
+ COPY app.py ./ # Make sure app.py exists in your build directory
24
  COPY test.js ./
 
25
 
26
+ # -------------------- Node Dependencies --------------------
27
+ RUN npm install youtube-po-token-generator
28
 
29
+ # -------------------- Cache Permissions for pytubefix --------------------
30
+ # Let pytubefix write to its cache without permission issues
31
+ RUN mkdir -p /usr/local/lib/python3.9/site-packages/pytubefix/__cache__ && \
32
+ chmod -R 777 /usr/local/lib/python3.9/site-packages/pytubefix/__cache__
33
 
34
+ # -------------------- Logs File --------------------
35
+ RUN touch logs.json && chmod 666 logs.json
36
 
37
+ # -------------------- Expose Port --------------------
38
  EXPOSE 7860
39
 
40
+ # -------------------- Start FastAPI App --------------------
41
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "2"]