Skip to content

Commit f002de7

Browse files
author
Fernando Ledesma
committed
added dockerfile
1 parent 0ae5332 commit f002de7

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

mdk-nextjs-demo/Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#syntax=docker.io/docker/dockerfile:1
2+
3+
FROM node:20-alpine AS base
4+
5+
# Dependencies stage
6+
FROM base AS dependencies
7+
WORKDIR /app
8+
9+
# Install curl and jq for healthchecks and JSON manipulation
10+
RUN apk add --no-cache curl libc6-compat jq
11+
12+
# Copy package files
13+
COPY package.json package-lock.json* ./
14+
15+
# Install dependencies
16+
RUN npm install
17+
18+
# Copy the rest of the app
19+
COPY . .
20+
21+
# Builder stage - creates production build
22+
FROM dependencies AS builder
23+
WORKDIR /app
24+
25+
# Build the Next.js app with all env vars available
26+
RUN npm run build
27+
28+
# Production image - run Next.js in production mode
29+
FROM base AS production
30+
WORKDIR /app
31+
32+
# Install curl for healthchecks
33+
RUN apk add --no-cache curl libc6-compat
34+
35+
# Copy necessary files from builder
36+
COPY --from=builder /app/package.json ./
37+
COPY --from=builder /app/node_modules ./node_modules
38+
COPY --from=builder /app/.next ./.next
39+
COPY --from=builder /app/next.config.mjs ./next.config.mjs
40+
41+
EXPOSE 3000
42+
43+
ENV PORT=3000
44+
ENV HOSTNAME="0.0.0.0"
45+
ENV NODE_ENV=production
46+
47+
# Start Next.js in production mode
48+
CMD ["npm", "start"]

0 commit comments

Comments
 (0)