Git Product home page Git Product logo

Comments (1)

deadcoder0904 avatar deadcoder0904 commented on May 28, 2024

yeah, i keep getting this on a clean docker build. idk why.

#13 1.322 ? The modules directory at "/app/node_modules" will be removed and reinstalled from scratch. Proceed? (Y/n) ‣ true
#13 DONE 1.5s

#14 [web development 7/8] RUN pnpm install [email protected]
#14 1.154  ERR_PNPM_UNEXPECTED_STORE  Unexpected store location
#14 1.154
#14 1.154 The dependencies at "/app/node_modules" are currently linked from the store at "/home/node/.pnpm-store/v3".
#14 1.154
#14 1.154 pnpm now wants to use the store at "/root/.local/share/pnpm/store/v3" to link dependencies.
#14 1.154
#14 1.154 If you want to use the new store location, reinstall your dependencies with "pnpm install".
#14 1.154
#14 1.154 You may change the global store location by running "pnpm config set store-dir <dir> --global".
#14 1.154 (This error may happen if the node_modules was installed with a different major version of pnpm)
#14 ERROR: process "/bin/sh -c pnpm install [email protected]" did not complete successfully: exit code: 1
------
 > [web development 7/8] RUN pnpm install [email protected]:
1.154  ERR_PNPM_UNEXPECTED_STORE  Unexpected store location
1.154
1.154 The dependencies at "/app/node_modules" are currently linked from the store at "/home/node/.pnpm-store/v3".
1.154
1.154 pnpm now wants to use the store at "/root/.local/share/pnpm/store/v3" to link dependencies.
1.154
1.154 If you want to use the new store location, reinstall your dependencies with "pnpm install".
1.154
1.154 You may change the global store location by running "pnpm config set store-dir <dir> --global".
1.154 (This error may happen if the node_modules was installed with a different major version of pnpm)
------
failed to solve: process "/bin/sh -c pnpm install [email protected]" did not complete successfully: exit code: 1
make: *** [Makefile:3: build-dev] Error 17

for context, this is my current dockerfile:

FROM node:20-alpine AS base

# mostly inspired from https://github.com/BretFisher/node-docker-good-defaults/blob/main/Dockerfile & https://github.com/remix-run/example-trellix/blob/main/Dockerfile

# 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 corepack enable && corepack prepare [email protected] --activate

# 1. Install all dependencies including devDependencies
FROM base AS development
# Root user is implicit so you don't have to actually specify it. From https://stackoverflow.com/a/45553149/6141587
# USER root
USER node
# WORKDIR now sets correct permissions if you set USER first so `USER node` has permissions on `/app` directory
WORKDIR /app

# set the store dir to a folder that is not in the project
RUN pnpm config set store-dir ~/.pnpm-store

# Install dependencies based on the preferred package manager
COPY --chown=node:node package.json pnpm-lock.yaml ./
RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm fetch

ENV NODE_ENV development
ENV NEXT_TELEMETRY_DISABLED 1

# Copied from https://stackoverflow.com/a/69867550/6141587
USER root
# Give /data directory correct permissions otherwise WAL mode won't work. It means you can't have 2 users writing to the database at the same time without this line as *.sqlite-wal & *.sqlite-shm are automatically created & deleted when *.sqlite is busy.
RUN mkdir -p /data && chown -R node:node /data

RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm install --frozen-lockfile --recursive --prefer-offline
RUN pnpm install [email protected]

COPY --chown=node:node . .
USER node

# 2. Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
# Inspired by https://github.com/vercel/next.js/discussions/36935
RUN mkdir -p /app/.next/cache && chown -R node:node /app/.next/cache
# Persist the next cache in a volume
VOLUME ["/app/.next/cache"]
COPY --from=development --chown=node:node /app/node_modules ./node_modules

COPY --chown=node:node . .

# This will do the trick, use the corresponding env file for each environment.
COPY --chown=node:node .env* ./

# set to production otherwise it throws error ⚠ You are using a non-standard "NODE_ENV" value in your environment. This creates inconsistencies in the project and is strongly advised against. Read more: https://nextjs.org/docs/messages/non-standard-node-env
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

RUN pnpm build

# 3. Production image, copy all the files and run next
FROM base AS runner
USER node
WORKDIR /app

EXPOSE 3000

ENV PORT 3000
ENV HOSTNAME 0.0.0.0
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

COPY --from=builder --chown=node:node /app/.env* ./
COPY --from=builder --chown=node:node /app/public ./public

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=node:node /app/.next/standalone ./
COPY --from=builder --chown=node:node /app/.next/static ./.next/static

# Move the drizzle directory to the runtime image
COPY --from=builder --chown=node:node /app/src/app/db/migrations ./migrations

# Move the litestream binary to the runtime image from the litestream image
# You can use a specific version of litestream by changing the tag
# COPY --from=litestream/litestream:0.3.13 /usr/local/bin/litestream /usr/local/bin/litestream
COPY --from=litestream/litestream:latest --chown=node:node /usr/local/bin/litestream /usr/local/bin/litestream
COPY --from=builder --chown=node:node /app/litestream.yml /etc/litestream.yml

COPY --from=builder --chown=node:node /app/scripts ./scripts

only faced it after i moved some things around like COPY . . in development stage.

from pnpm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.