You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having trouble installing sharp to the with-docker example. I'm using pnpm. I have it in my package.json, but during the docker build I can see it's not available in node_modules. I have tried copying from the installer node_modules to the runner stage, and I have tried installing it globally, but I still end up with the "Error: 'sharp' is required to be installed in standalone mode for the image optimization to function correctly."
Am I missing something?
Here's my Docker:
FROM node:20-alpine AS base
ENV PNPM_HOME="/pnpm"ENV PATH="$PNPM_HOME:$PATH"RUN npm install -g pnpm && pnpm add -g turbo
FROM base AS builder
RUN apk add --no-cache libc6-compat
RUN apk update
# Set working directoryWORKDIR /app
COPY . .
RUN turbo prune @app/merlin --docker
# remove all empty node_modules folder structureRUN rm -rf /app/out/full/*/*/node_modules
# Add lockfile and package.json's of isolated subworkspaceFROM base AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
# First install the dependencies (as they change less often)COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install
# Next.js collects completely anonymous telemetry data about general usage.# Learn more here: https://nextjs.org/telemetryENV NEXT_TELEMETRY_DISABLED 1
# Build the projectCOPY --from=builder /app/out/full/ .
RUN turbo run build --filter=@app/merlin
FROM base AS runner
WORKDIR /app
# Latest test to get sharp workingRUN npm i -g --arch=x64 --platform=linux --libc=glibc [email protected]# Don't run production as rootRUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs
EXPOSE 3000
ENV PORT 3000
ENV HOSTNAME 0.0.0.0
COPY --from=installer /app/apps/nextjs/next.config.mjs .
COPY --from=installer /app/apps/nextjs/package.json .
# Automatically leverage output traces to reduce image size# https://nextjs.org/docs/advanced-features/output-file-tracingCOPY --from=installer --chown=nextjs:nodejs /app/apps/nextjs/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/nextjs/.next/static ./apps/nextjs/.next/static
COPY --from=installer --chown=nextjs:nodejs /app/apps/nextjs/public ./apps/nextjs/public
ENV NEXT_TELEMETRY_DISABLED 1
# Copy migrations overCOPY apps/nextjs/src/server/db/migrations /app/apps/nextjs/src/server/db/migrations
CMD node apps/nextjs/server.js
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello
I'm having trouble installing
sharp
to thewith-docker
example. I'm using pnpm. I have it in my package.json, but during the docker build I can see it's not available innode_modules
. I have tried copying from the installer node_modules to the runner stage, and I have tried installing it globally, but I still end up with the "Error: 'sharp' is required to be installed in standalone mode for the image optimization to function correctly."Am I missing something?
Here's my Docker:
Thanks for reading!
Beta Was this translation helpful? Give feedback.
All reactions