Skip to content

Commit

Permalink
feat: fix workflow to nextjs
Browse files Browse the repository at this point in the history
  • Loading branch information
bombnp committed Jul 21, 2024
1 parent aab2557 commit 4966bb8
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM node:20-alpine as deps
FROM node:20-alpine AS base

FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app

COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
Expand All @@ -10,11 +11,8 @@ RUN \
else echo "Lockfile not found." && exit 1; \
fi

COPY . ./

FROM deps as builder
FROM base AS builder
WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY . .

Expand All @@ -25,8 +23,27 @@ RUN \
else echo "Lockfile not found." && exit 1; \
fi

FROM nginx:latest as prod

COPY --from=builder /app/dist /usr/share/nginx/html
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production

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

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

RUN mkdir .next
RUN chown nextjs:nodejs .next

COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT 3000

CMD ["nginx", "-g", "daemon off;"]
CMD HOSTNAME="0.0.0.0" node server.js

0 comments on commit 4966bb8

Please sign in to comment.