Spaces:
Runtime error
Runtime error
Hanzo Dev
commited on
Commit
·
d8886c0
1
Parent(s):
b60887c
Optimize Docker for faster startup
Browse files- Dockerfile +8 -8
- next.config.js +8 -0
Dockerfile
CHANGED
|
@@ -2,20 +2,20 @@ FROM node:20-slim
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
# Copy package files
|
| 6 |
COPY package*.json ./
|
| 7 |
|
| 8 |
-
# Install dependencies with legacy peer deps
|
| 9 |
-
RUN npm ci --legacy-peer-deps
|
| 10 |
|
| 11 |
-
# Copy application
|
| 12 |
COPY . .
|
| 13 |
|
| 14 |
-
# Build the
|
| 15 |
RUN npm run build
|
| 16 |
|
| 17 |
-
# Expose port
|
| 18 |
EXPOSE 3000
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
CMD ["
|
|
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
# Copy only package files first for better caching
|
| 6 |
COPY package*.json ./
|
| 7 |
|
| 8 |
+
# Install dependencies with legacy peer deps
|
| 9 |
+
RUN npm ci --legacy-peer-deps
|
| 10 |
|
| 11 |
+
# Copy the rest of the application
|
| 12 |
COPY . .
|
| 13 |
|
| 14 |
+
# Build the Next.js app
|
| 15 |
RUN npm run build
|
| 16 |
|
| 17 |
+
# Expose the port
|
| 18 |
EXPOSE 3000
|
| 19 |
|
| 20 |
+
# Use Node directly to avoid npm overhead
|
| 21 |
+
CMD ["node", ".next/standalone/server.js"]
|
next.config.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {import('next').NextConfig} */
|
| 2 |
+
const nextConfig = {
|
| 3 |
+
output: 'standalone',
|
| 4 |
+
reactStrictMode: true,
|
| 5 |
+
swcMinify: true,
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
module.exports = nextConfig
|