Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +21 -15
Dockerfile
CHANGED
|
@@ -1,27 +1,33 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
| 3 |
-
|
|
|
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
|
|
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
RUN
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
| 19 |
|
| 20 |
-
#
|
|
|
|
|
|
|
|
|
|
| 21 |
RUN npm install
|
| 22 |
|
| 23 |
-
# Expose port (adjust if needed)
|
| 24 |
EXPOSE 3000
|
| 25 |
|
| 26 |
# Start the app
|
| 27 |
-
CMD ["npm", "
|
|
|
|
| 1 |
+
# Use an official Node.js image (adjust version as needed)
|
| 2 |
+
FROM node:20
|
| 3 |
|
| 4 |
+
# Create a non-root user with UID 1000 (matches HF Spaces)
|
| 5 |
+
RUN useradd -m -u 1000 user
|
| 6 |
|
| 7 |
+
# Set environment variables for the user
|
| 8 |
+
ENV HOME=/home/user \
|
| 9 |
+
PATH=/home/user/.local/bin:$PATH
|
| 10 |
|
| 11 |
+
# Set working directory inside the user's home
|
| 12 |
+
WORKDIR $HOME/app
|
| 13 |
|
| 14 |
+
# Install unzip and any other utilities
|
| 15 |
+
RUN apt-get update && apt-get install -y unzip && rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
+
# Copy zip file with correct ownership
|
| 18 |
+
COPY --chown=user:user Archive.zip .
|
| 19 |
|
| 20 |
+
# Unzip as root (so unzip is available) then change ownership in one step
|
| 21 |
+
RUN unzip Archive.zip && rm Archive.zip && chown -R user:user $HOME/app
|
| 22 |
|
| 23 |
+
# Switch to the non-root user
|
| 24 |
+
USER user
|
| 25 |
+
|
| 26 |
+
# Install dependencies
|
| 27 |
RUN npm install
|
| 28 |
|
| 29 |
+
# Expose the app port (adjust if needed)
|
| 30 |
EXPOSE 3000
|
| 31 |
|
| 32 |
# Start the app
|
| 33 |
+
CMD ["npm", "start"]
|