Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +12 -15
Dockerfile
CHANGED
|
@@ -1,32 +1,29 @@
|
|
| 1 |
-
# Use an official Node.js image
|
| 2 |
FROM node:20
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
|
|
|
| 6 |
|
| 7 |
-
# Set
|
| 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=
|
| 19 |
|
| 20 |
-
# Unzip as root (so unzip
|
| 21 |
-
RUN unzip Archive.zip && rm Archive.zip && chown -R
|
| 22 |
|
| 23 |
-
# Switch to the non-root user
|
| 24 |
-
USER
|
| 25 |
|
| 26 |
# Install dependencies
|
| 27 |
RUN npm install
|
| 28 |
|
| 29 |
-
# Expose the app port
|
| 30 |
EXPOSE 3000
|
| 31 |
|
| 32 |
# Start the app
|
|
|
|
| 1 |
+
# Use an official Node.js image
|
| 2 |
FROM node:20
|
| 3 |
|
| 4 |
+
# Set environment variables for node user
|
| 5 |
+
ENV HOME=/home/node \
|
| 6 |
+
PATH=/home/node/.local/bin:$PATH
|
| 7 |
|
| 8 |
+
# Set working directory inside node's home
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
WORKDIR $HOME/app
|
| 10 |
|
| 11 |
# Install unzip and any other utilities
|
| 12 |
RUN apt-get update && apt-get install -y unzip && rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
+
# Copy zip file with correct ownership directly to the app folder
|
| 15 |
+
COPY --chown=node:node Archive.zip .
|
| 16 |
|
| 17 |
+
# Unzip as root (so unzip works) then fix permissions in one step
|
| 18 |
+
RUN unzip Archive.zip && rm Archive.zip && chown -R node:node $HOME/app
|
| 19 |
|
| 20 |
+
# Switch to the non-root node user
|
| 21 |
+
USER node
|
| 22 |
|
| 23 |
# Install dependencies
|
| 24 |
RUN npm install
|
| 25 |
|
| 26 |
+
# Expose the app port
|
| 27 |
EXPOSE 3000
|
| 28 |
|
| 29 |
# Start the app
|