Skip to content

Commit

Permalink
πŸ’š ci: better dockerfile (only supporting pnpm)
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev>
  • Loading branch information
mhkarimi1383 committed Jun 7, 2024
1 parent 5dec550 commit fba430a
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN --mount=type=cache,target=/app/node_modules \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi
RUN --mount=type=cache,target=/root/.pnpm-store \
corepack enable pnpm && pnpm i --frozen-lockfile


# Rebuild the source code only when needed
Expand All @@ -24,11 +20,7 @@ COPY . .
ENV NEXT_TELEMETRY_DISABLED 1

RUN --mount=type=cache,target=/app/.next/cache \
if [ -f yarn.lock ]; then yarn run build; \
elif [ -f package-lock.json ]; then npm run build; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
else echo "Lockfile not found." && exit 1; \
fi
corepack enable pnpm && pnpm run build

# Production image, copy all the files and run next
FROM base AS runner
Expand Down

0 comments on commit fba430a

Please sign in to comment.