Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +8 -27
Dockerfile
CHANGED
|
@@ -1,41 +1,22 @@
|
|
| 1 |
-
# Use Node.js 20 on Alpine Linux for a lightweight image
|
| 2 |
FROM node:20-alpine
|
| 3 |
|
| 4 |
-
# Install compatibility libraries (libc6-compat) required for Next.js on Alpine
|
| 5 |
RUN apk add --no-cache libc6-compat
|
| 6 |
|
| 7 |
-
# Set the working directory
|
| 8 |
WORKDIR /app
|
| 9 |
|
| 10 |
-
# Copy package.json and package-lock.json first to leverage Docker layer caching
|
| 11 |
COPY package.json package-lock.json ./
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
#
|
| 15 |
-
RUN npm
|
| 16 |
|
| 17 |
-
# Copy the rest of the application source code
|
| 18 |
COPY . .
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
# Note:
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
# Create a non-root user for security
|
| 25 |
-
RUN addgroup --system --gid 1001 nodejs && \
|
| 26 |
-
adduser --system --uid 1001 nextjs && \
|
| 27 |
-
chown -R nextjs:nodejs /app
|
| 28 |
-
|
| 29 |
-
# Switch to the non-root user
|
| 30 |
-
USER nextjs
|
| 31 |
|
| 32 |
-
|
| 33 |
-
ENV NODE_ENV=production
|
| 34 |
-
# Hugging Face Spaces specifically requires port 7860
|
| 35 |
-
ENV PORT=7860
|
| 36 |
-
|
| 37 |
-
# Expose the port
|
| 38 |
-
EXPOSE 7860
|
| 39 |
|
| 40 |
-
# Start the application
|
| 41 |
CMD ["npm", "start"]
|
|
|
|
|
|
|
| 1 |
FROM node:20-alpine
|
| 2 |
|
|
|
|
| 3 |
RUN apk add --no-cache libc6-compat
|
| 4 |
|
|
|
|
| 5 |
WORKDIR /app
|
| 6 |
|
|
|
|
| 7 |
COPY package.json package-lock.json ./
|
| 8 |
|
| 9 |
+
# Use npm install instead of npm ci to handle lock file discrepancies automatically
|
| 10 |
+
# This prevents the "Missing ... from lock file" error
|
| 11 |
+
RUN npm install --legacy-peer-deps
|
| 12 |
|
|
|
|
| 13 |
COPY . .
|
| 14 |
|
| 15 |
+
# Environment variables for build time (if needed by Next.js build)
|
| 16 |
+
# Note: Secrets are usually injected by the platform, but we can set defaults or placeholders
|
| 17 |
+
# ENV DATABASE_URL=...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
RUN npm run build
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
# Start the application with the drizzle push command included in package.json start script
|
| 22 |
CMD ["npm", "start"]
|