Skip to content

Instantly share code, notes, and snippets.

@julianapeace
Created September 24, 2025 19:42
Show Gist options
  • Select an option

  • Save julianapeace/a437e23c8737dccb3cd1867cbc9eb6ee to your computer and use it in GitHub Desktop.

Select an option

Save julianapeace/a437e23c8737dccb3cd1867cbc9eb6ee to your computer and use it in GitHub Desktop.
challenge #2
# Use Node.js 24 slim for ARM64 architecture
FROM --platform=linux/arm64 node:24-slim AS base
# Install dependencies only when needed
FROM base AS deps
WORKDIR /app
# Copy package files first
COPY package.json package-lock.json* ./
# Install dependencies
RUN npm install
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Build the application
RUN npm run build
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
# Copy built application
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
# Use node to run the standalone server
CMD ["node", "server.js"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment