Spaces:
Running on Zero
Running on Zero
Manoj Kumar Thapa commited on
Commit ·
da0ee08
1
Parent(s): e8d4073
Fix Hugging Face Docker permissions
Browse files- Dockerfile +10 -8
Dockerfile
CHANGED
|
@@ -2,7 +2,6 @@
|
|
| 2 |
FROM node:18 AS frontend-builder
|
| 3 |
WORKDIR /app/frontend
|
| 4 |
|
| 5 |
-
# Copy frontend source
|
| 6 |
COPY frontend/package*.json ./
|
| 7 |
RUN npm install
|
| 8 |
|
|
@@ -18,21 +17,24 @@ RUN apt-get update && apt-get install -y \
|
|
| 18 |
poppler-utils \
|
| 19 |
&& rm -rf /var/lib/apt/lists/*
|
| 20 |
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
# Copy Backend requirements
|
| 24 |
-
COPY backend/requirements.txt .
|
| 25 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 26 |
|
| 27 |
# Copy Backend Code
|
| 28 |
-
COPY backend/ .
|
| 29 |
|
| 30 |
# Copy Frontend Build Result
|
| 31 |
-
|
| 32 |
-
COPY --from=frontend-builder /app/frontend/dist ./frontend_static
|
| 33 |
|
| 34 |
-
# Expose Hugging Face Port
|
| 35 |
EXPOSE 7860
|
| 36 |
|
| 37 |
-
# Run FastAPI
|
| 38 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 2 |
FROM node:18 AS frontend-builder
|
| 3 |
WORKDIR /app/frontend
|
| 4 |
|
|
|
|
| 5 |
COPY frontend/package*.json ./
|
| 6 |
RUN npm install
|
| 7 |
|
|
|
|
| 17 |
poppler-utils \
|
| 18 |
&& rm -rf /var/lib/apt/lists/*
|
| 19 |
|
| 20 |
+
# Add a non-root user (Hugging Face requirement)
|
| 21 |
+
RUN useradd -m -u 1000 user
|
| 22 |
+
USER user
|
| 23 |
+
ENV HOME=/home/user \
|
| 24 |
+
PATH=/home/user/.local/bin:$PATH
|
| 25 |
+
|
| 26 |
+
WORKDIR $HOME/app
|
| 27 |
|
| 28 |
# Copy Backend requirements
|
| 29 |
+
COPY --chown=user backend/requirements.txt .
|
| 30 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 31 |
|
| 32 |
# Copy Backend Code
|
| 33 |
+
COPY --chown=user backend/ .
|
| 34 |
|
| 35 |
# Copy Frontend Build Result
|
| 36 |
+
COPY --chown=user --from=frontend-builder /app/frontend/dist ./frontend_static
|
|
|
|
| 37 |
|
|
|
|
| 38 |
EXPOSE 7860
|
| 39 |
|
|
|
|
| 40 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|