Skip to content

Commit

Permalink
Fixup Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
statico committed May 12, 2024
1 parent 9c64f52 commit 5bbb439
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Install dependencies only when needed
FROM node:20-alpine AS deps
FROM node:20-alpine AS base

# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat

RUN yarn global add pnpm

# Install dependencies only when needed
FROM base AS deps
WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i; \
else echo "Lockfile not found." && exit 1; \
fi
# Install dependencies
COPY package.json pnpm-lock.yaml* ./
RUN pnpm install

# Rebuild the source code only when needed
FROM node:20-alpine AS builder
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
Expand All @@ -24,7 +24,7 @@ ENV NEXT_TELEMETRY_DISABLED 1
RUN pnpm build

# Production image, copy all the files and run next
FROM node:20-alpine AS runner
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production
Expand All @@ -41,7 +41,7 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

# Needed for migrations
RUN pnpm global add knex
RUN yarn global add knex
COPY --from=builder /app/knexfile.js ./
COPY --from=builder /app/migrations ./migrations

Expand Down

0 comments on commit 5bbb439

Please sign in to comment.