Skip to content

Commit

Permalink
✨ feat: docker cache packages and next builds
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 4158575 commit 5dec550
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# syntax=docker/dockerfile:1
FROM node:20.14.0-bookworm AS base

# Install dependencies only when needed
Expand All @@ -6,7 +7,7 @@ WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
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; \
Expand All @@ -22,7 +23,7 @@ COPY . .

ENV NEXT_TELEMETRY_DISABLED 1

RUN \
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; \
Expand Down

0 comments on commit 5dec550

Please sign in to comment.