Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +9 -13
Dockerfile
CHANGED
@@ -5,35 +5,31 @@ RUN apt-get update && apt-get install -y \
|
|
5 |
build-essential \
|
6 |
&& rm -rf /var/lib/apt/lists/*
|
7 |
|
8 |
-
|
|
|
9 |
|
|
|
10 |
ENV API_TOKEN=$HF_TOKEN
|
11 |
|
12 |
-
#
|
13 |
WORKDIR /app
|
|
|
14 |
|
15 |
-
#
|
16 |
-
|
17 |
-
adduser --system --uid 1001 nextjs && \
|
18 |
-
chown -R nextjs:nodejs /app
|
19 |
|
20 |
# Copy package files
|
21 |
-
COPY --chown=
|
22 |
|
23 |
# Install dependencies
|
24 |
RUN npm install
|
25 |
|
26 |
# Copy the rest of the application
|
27 |
-
COPY --chown=
|
28 |
-
|
29 |
-
# Switch to non-root user
|
30 |
-
USER nextjs
|
31 |
|
32 |
# Build the Next.js application
|
33 |
RUN npm run build
|
34 |
|
35 |
-
# Expose the port the app runs on
|
36 |
EXPOSE 3001
|
37 |
|
38 |
-
# Start the application
|
39 |
CMD ["npm", "start"]
|
|
|
5 |
build-essential \
|
6 |
&& rm -rf /var/lib/apt/lists/*
|
7 |
|
8 |
+
# Change node user ID to match host user ID
|
9 |
+
RUN usermod -u 1000 node
|
10 |
|
11 |
+
ARG HF_TOKEN
|
12 |
ENV API_TOKEN=$HF_TOKEN
|
13 |
|
14 |
+
# Set working directory and ownership
|
15 |
WORKDIR /app
|
16 |
+
RUN chown -R node:node /app
|
17 |
|
18 |
+
# Switch to node user
|
19 |
+
USER node
|
|
|
|
|
20 |
|
21 |
# Copy package files
|
22 |
+
COPY --chown=node:node package*.json ./
|
23 |
|
24 |
# Install dependencies
|
25 |
RUN npm install
|
26 |
|
27 |
# Copy the rest of the application
|
28 |
+
COPY --chown=node:node . .
|
|
|
|
|
|
|
29 |
|
30 |
# Build the Next.js application
|
31 |
RUN npm run build
|
32 |
|
|
|
33 |
EXPOSE 3001
|
34 |
|
|
|
35 |
CMD ["npm", "start"]
|