Skip to content

Commit 48fc37f

Browse files
committed
fix docker build and server error
1 parent bcd6805 commit 48fc37f

5 files changed

Lines changed: 15 additions & 14 deletions

File tree

Dockerfile

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Stage 1: Build the production assets
2-
FROM node:22-alpine AS builder
2+
FROM node:22 AS builder
33

44
WORKDIR /app
55

@@ -10,27 +10,25 @@ RUN npm install
1010
# Copy the rest of your application code
1111
COPY . .
1212

13-
# Build the production assets; this creates the .next directory
13+
# Build the production assets (standalone output)
1414
RUN npm run build
1515

1616
# Stage 2: Run the production app
17-
FROM node:22-alpine AS runner
17+
FROM node:22-slim AS runner
1818

1919
WORKDIR /app
2020

21-
# Copy only the necessary files from the builder stage
22-
COPY --from=builder /app/package*.json ./
23-
COPY --from=builder /app/.next ./.next
24-
COPY --from=builder /app/public ./public
21+
ENV NODE_ENV=production
2522

26-
# (Optional) Copy any other files you need in production
27-
# COPY --from=builder /app/src ./src
23+
# Copy the standalone server (includes all needed node_modules)
24+
COPY --from=builder /app/.next/standalone ./
2825

29-
# Install only production dependencies
30-
RUN npm ci --production
26+
# Copy static assets and public files (not included in standalone)
27+
COPY --from=builder /app/.next/static ./.next/static
28+
COPY --from=builder /app/public ./public
3129

3230
# Expose the port your app listens on
3331
EXPOSE 3000
3432

35-
# Start the production server
36-
CMD ["npm", "run", "start"]
33+
# Start the standalone server
34+
CMD ["node", "server.js"]

next.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const nextConfig = {
88
reactStrictMode: true,
99
trailingSlash: true,
1010
turbopack: {},
11+
output: 'standalone',
1112
};
1213

1314
module.exports =

0 commit comments

Comments
 (0)