Skip to content

Commit

Permalink
fix: dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
oproprioleonardo committed Sep 16, 2024
1 parent 768fde6 commit 37af0ec
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ RUN \
else echo "Lockfile not found." && exit 1; \
fi


# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Add debug step to list files
RUN ls -la /app
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED 1


RUN \
if [ -f yarn.lock ]; then yarn run build; \
Expand All @@ -35,7 +39,18 @@ RUN \
FROM base AS runner
WORKDIR /app

ENV NODE_ENV=production
ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED 1

COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./

RUN \
if [ -f yarn.lock ]; then yarn global add pm2; \
elif [ -f package-lock.json ]; then npm install -g pm2; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm add -g pm2; \
else echo "Lockfile not found." && exit 1; \
fi

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
Expand All @@ -55,8 +70,9 @@ USER nextjs

EXPOSE 3000

ENV PORT=3000
ENV 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 ["node", "server.js"]

CMD ["pm2-runtime", "server.js"]

0 comments on commit 37af0ec

Please sign in to comment.