Spaces:
Runtime error
Runtime error
Hoe commited on
Commit ·
e2b9650
1
Parent(s): 80ba76e
Fixing permissions and paths
Browse files- Dockerfile +15 -4
Dockerfile
CHANGED
|
@@ -1,12 +1,23 @@
|
|
| 1 |
FROM node:18
|
|
|
|
|
|
|
| 2 |
RUN useradd -m -u 1000 user
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
USER user
|
| 4 |
-
|
| 5 |
-
|
| 6 |
COPY --chown=user package*.json ./
|
| 7 |
RUN npm install
|
|
|
|
|
|
|
| 8 |
COPY --chown=user . .
|
| 9 |
-
|
|
|
|
| 10 |
ENV PORT=7860
|
| 11 |
EXPOSE 7860
|
| 12 |
-
CMD ["node", "index.js"]
|
|
|
|
| 1 |
FROM node:18
|
| 2 |
+
|
| 3 |
+
# 1. Create user and directory as root first
|
| 4 |
RUN useradd -m -u 1000 user
|
| 5 |
+
RUN mkdir -p /home/user/app && chown -R user:user /home/user/app
|
| 6 |
+
|
| 7 |
+
# 2. Set working directory
|
| 8 |
+
WORKDIR /home/user/app
|
| 9 |
+
|
| 10 |
+
# 3. Switch to the non-root user
|
| 11 |
USER user
|
| 12 |
+
|
| 13 |
+
# 4. Copy and install
|
| 14 |
COPY --chown=user package*.json ./
|
| 15 |
RUN npm install
|
| 16 |
+
|
| 17 |
+
# 5. Copy the rest of the code
|
| 18 |
COPY --chown=user . .
|
| 19 |
+
|
| 20 |
+
# 6. Set environment and start
|
| 21 |
ENV PORT=7860
|
| 22 |
EXPOSE 7860
|
| 23 |
+
CMD ["node", "index.js"]
|