Skip to content

Commit

Permalink
chore: update dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua-Ogbonna committed Dec 30, 2024
1 parent f39c12f commit 7781f1c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node-linker=hoisted
shamefully-hoist=true
strict-peer-dependencies=false
strict-peer-dependencies=false
legacy-peer-deps=true
auto-install-peers=true
26 changes: 14 additions & 12 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,25 @@ RUN apk add --no-cache \
g++ \
build-base

# Install pnpm globally
RUN npm install -g pnpm@latest
# Install pnpm globally with specific version
RUN npm install -g pnpm@8.15.1

WORKDIR /app

# Copy package.json and pnpm-lock.yaml
COPY package.json pnpm-lock.yaml ./
# Copy package configs
COPY package.json pnpm-lock.yaml .npmrc ./

# Install dependencies with pnpm (with additional flags for better error handling)
RUN pnpm install --frozen-lockfile --verbose
# First, try to install dependencies with frozen lockfile
RUN pnpm install --frozen-lockfile --verbose || \
# If that fails, try without frozen lockfile
(rm -rf node_modules && pnpm install --no-frozen-lockfile --verbose)

# Rebuild the source code only when needed
FROM node:18-alpine AS builder
WORKDIR /app

# Install pnpm globally
RUN npm install -g pnpm@latest
# Install pnpm globally with specific version
RUN npm install -g pnpm@8.15.1

# Copy all files from deps stage
COPY --from=deps /app/node_modules ./node_modules
Expand All @@ -41,8 +43,8 @@ RUN pnpm run build
FROM node:18-alpine AS runner
WORKDIR /app

# Install pnpm globally
RUN npm install -g pnpm@latest
# Install pnpm globally with specific version
RUN npm install -g pnpm@8.15.1

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
Expand All @@ -53,8 +55,8 @@ RUN adduser --system --uid 1001 nextjs
# Copy necessary files
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static

# Ensure proper permissions
RUN chmod -R 777 ./public
Expand Down

0 comments on commit 7781f1c

Please sign in to comment.