Spaces:
Sleeping
Sleeping
trae-bot commited on
Commit ·
982bf96
1
Parent(s): cbed33a
fix: resolve huggingface space deployment permission and missing uploads dir issue
Browse files- Dockerfile +14 -4
Dockerfile
CHANGED
|
@@ -1,14 +1,24 @@
|
|
| 1 |
FROM node:20-bullseye-slim
|
| 2 |
|
|
|
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
RUN npm --prefix frontend install --no-audit --no-fund && npm --prefix backend ci
|
| 9 |
|
| 10 |
-
|
| 11 |
-
COPY
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
RUN npm --prefix frontend run build && npm --prefix backend run build
|
| 14 |
|
|
|
|
| 1 |
FROM node:20-bullseye-slim
|
| 2 |
|
| 3 |
+
# Create app directory and set ownership to the existing 'node' user (UID 1000)
|
| 4 |
+
RUN mkdir -p /app && chown node:node /app
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Switch to the non-root user
|
| 8 |
+
USER node
|
| 9 |
+
|
| 10 |
+
# Copy package files with correct ownership
|
| 11 |
+
COPY --chown=node:node frontend/package.json ./frontend/package.json
|
| 12 |
+
COPY --chown=node:node backend/package.json backend/package-lock.json ./backend/
|
| 13 |
|
| 14 |
RUN npm --prefix frontend install --no-audit --no-fund && npm --prefix backend ci
|
| 15 |
|
| 16 |
+
# Copy source code with correct ownership
|
| 17 |
+
COPY --chown=node:node frontend ./frontend
|
| 18 |
+
COPY --chown=node:node backend ./backend
|
| 19 |
+
|
| 20 |
+
# Create uploads directory so backend can serve static files
|
| 21 |
+
RUN mkdir -p backend/uploads
|
| 22 |
|
| 23 |
RUN npm --prefix frontend run build && npm --prefix backend run build
|
| 24 |
|