-
-
Save pratikbin/c32af352272a928376a24921cdb56a67 to your computer and use it in GitHub Desktop.
Discord challenge #2 - This dockerfile will not build on NodeOps. What is wrong with it?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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