Skip to content

Commit

Permalink
refactor(build): docker image (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
seth2810 authored Aug 15, 2024
1 parent ba3d898 commit 96a1be6
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
FROM node:20.10.0-alpine as base
########################################
# BASE #################################
########################################
FROM node:20.16.0-alpine as base

ENV NEXT_TELEMETRY_DISABLED=1 NODE_ENV=production YARN_VERSION=4.1.1

RUN apk update && apk upgrade && apk add --no-cache libc6-compat

RUN corepack enable && corepack prepare yarn@${YARN_VERSION}

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

#########################################
# BUILD #################################
#########################################
FROM base AS builder

WORKDIR /app

COPY . .
COPY package.json yarn.lock .yarnrc.yml ./
COPY .yarn ./.yarn
RUN yarn install --immutable

RUN yarn install --immutable
RUN yarn build

#########################################
# RELEASE ###############################
#########################################
FROM base AS runner

WORKDIR /app

COPY --from=builder --chown=nextjs:nodejs /app/public ./public
Expand All @@ -38,8 +49,8 @@ USER nextjs

EXPOSE 3000

ENV PORT 3000
ENV HOSTNAME=0.0.0.0 PORT=3000

# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
CMD HOSTNAME="0.0.0.0" node server.js
CMD ["node", "--inspect=9229", "server.js"]

0 comments on commit 96a1be6

Please sign in to comment.