Skip to content

Commit

Permalink
Merge branch 'production' of https://github.com/real-token/realtoken-…
Browse files Browse the repository at this point in the history
…yam-interface into production
  • Loading branch information
jeanbenoit-richez committed Nov 16, 2023
2 parents 994ad8b + 36c07a2 commit c3cef5e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM node:16-alpine AS base

# 1. Install dependencies only when needed
FROM node:16-alpine AS deps
FROM base 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

Expand All @@ -12,7 +14,7 @@ RUN yarn --frozen-lockfile


# 2. Rebuild the source code only when needed
FROM node:16-alpine AS builder
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
Expand All @@ -32,16 +34,21 @@ RUN grep COMMUNITY_API_KEY ./.env
RUN yarn build

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

ENV NODE_ENV=production

RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

# Set the correct permission for prerender cache
# https://github.com/vercel/next.js/pull/54870
RUN mkdir .next
RUN chown nextjs:nodejs .next

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
Expand Down

0 comments on commit c3cef5e

Please sign in to comment.