Skip to content

need help to dockerize #185

Answered by timlrx
eleach asked this question in Q&A
Aug 10, 2021 · 3 comments · 3 replies
Discussion options

You must be logged in to vote

Here's my working Dockerfile

# Install dependencies only when needed
FROM node:14-alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install

# Rebuild the source code only when needed
FROM node:14-alpine AS builder
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
RUN npm run build

# Production image, copy all the files and run next
FROM node:14-alpine AS runner
WORKDIR /app

ENV NODE_ENV production

RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 10…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@eleach
Comment options

@timlrx
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by eleach
Comment options

You must be logged in to vote
1 reply
@timlrx
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants