Maouu commited on
Commit
736319f
·
verified ·
1 Parent(s): d8c071d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -12
Dockerfile CHANGED
@@ -1,44 +1,49 @@
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
  node -v && npm -v
12
 
13
- # ---------- Set working directory ----------
14
  WORKDIR /app
15
 
16
- # ---------- Python dependencies ----------
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.js setup ----------
22
  COPY test.js ./
23
  RUN npm install youtube-po-token-generator
24
 
25
- # ---------- App code ----------
26
  COPY . .
27
 
28
- # ---------- Logging and permissions ----------
 
 
 
 
 
29
  RUN touch logs.json && \
30
  chown 1000:1000 logs.json && \
31
  chmod 664 logs.json
32
 
33
- # ---------- Create non-root user ----------
34
  RUN useradd -m -u 1000 user
35
  USER user
36
 
37
- # ---------- Environment ----------
38
  ENV PATH="/home/user/.local/bin:$PATH"
39
 
40
- # ---------- Expose default Hugging Face Spaces port ----------
41
  EXPOSE 7860
42
 
43
- # ---------- Start FastAPI with uvicorn ----------
44
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
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", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "2"]