Spaces:
Build error
Build error
Update Dockerfile
Browse files- Dockerfile +17 -12
Dockerfile
CHANGED
@@ -1,44 +1,49 @@
|
|
1 |
FROM python:3.9-slim
|
2 |
|
3 |
-
#
|
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 |
-
#
|
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 |
-
#
|
14 |
WORKDIR /app
|
15 |
|
16 |
-
#
|
17 |
COPY requirements.txt .
|
18 |
RUN pip install --no-cache-dir --upgrade pip && \
|
19 |
pip install --no-cache-dir -r requirements.txt
|
20 |
|
21 |
-
#
|
22 |
COPY test.js ./
|
23 |
RUN npm install youtube-po-token-generator
|
24 |
|
25 |
-
#
|
26 |
COPY . .
|
27 |
|
28 |
-
#
|
|
|
|
|
|
|
|
|
|
|
29 |
RUN touch logs.json && \
|
30 |
chown 1000:1000 logs.json && \
|
31 |
chmod 664 logs.json
|
32 |
|
33 |
-
#
|
34 |
RUN useradd -m -u 1000 user
|
35 |
USER user
|
36 |
|
37 |
-
#
|
38 |
ENV PATH="/home/user/.local/bin:$PATH"
|
39 |
|
40 |
-
#
|
41 |
EXPOSE 7860
|
42 |
|
43 |
-
#
|
44 |
-
CMD ["uvicorn", "
|
|
|
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"]
|