Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +11 -4
Dockerfile
CHANGED
|
@@ -9,20 +9,27 @@ ARG HF_TOKEN
|
|
| 9 |
|
| 10 |
ENV API_TOKEN=$HF_TOKEN
|
| 11 |
|
| 12 |
-
#
|
| 13 |
WORKDIR /app
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
# Copy package files
|
| 16 |
-
COPY package*.json ./
|
| 17 |
|
| 18 |
# Install dependencies
|
| 19 |
RUN npm install
|
| 20 |
|
| 21 |
# Copy the rest of the application
|
| 22 |
-
COPY . .
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
# Build the Next.js application
|
| 25 |
-
# Note: We don't use turbopack for production builds
|
| 26 |
RUN npm run build
|
| 27 |
|
| 28 |
# Expose the port the app runs on
|
|
|
|
| 9 |
|
| 10 |
ENV API_TOKEN=$HF_TOKEN
|
| 11 |
|
| 12 |
+
# Create app directory and set permissions
|
| 13 |
WORKDIR /app
|
| 14 |
|
| 15 |
+
# Create a non-root user
|
| 16 |
+
RUN addgroup --system --gid 1001 nodejs && \
|
| 17 |
+
adduser --system --uid 1001 nextjs && \
|
| 18 |
+
chown -R nextjs:nodejs /app
|
| 19 |
+
|
| 20 |
# Copy package files
|
| 21 |
+
COPY --chown=nextjs:nodejs package*.json ./
|
| 22 |
|
| 23 |
# Install dependencies
|
| 24 |
RUN npm install
|
| 25 |
|
| 26 |
# Copy the rest of the application
|
| 27 |
+
COPY --chown=nextjs:nodejs . .
|
| 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
|