Skip to content

Docker image downloads pnpm and prisma at startup #290

@leopold-gravier

Description

@leopold-gravier

Description

I tried to setup a splitpro server behind a strong firewall that did not let Splitpro make any outgoing request.
The prisma migration failed because corepack downloads pnpm which then downloads prisma (and its dependencies). All of this is done at runtime, each time the container is started.
This is an issue for performance reasons, and it also prevents to run split-pro with limited network access.

Steps to reproduce

See that prisma is installed at runtime

  1. docker run ossapps/splitpro:v1.4.7
  2. The logs show that pnpm downloads and installs some packages
    Progress: resolved 53, reused 0, downloaded 53, added 53, done
    .../[email protected]/node_modules/prisma preinstall$ node scripts/preinstall-entry.js
  3. (Since no database was configured in this minimal exemple, prisma will fail. The main point here is that prisma had to be downloaded at runtime)

See that pnpm is installed at runtime

  1. docker run --network none ossapps/splitpro:v1.4.7
  2. It fails to run the prisma migration with the following error:
    Error when performing the request to https://registry.npmjs.org/pnpm/-/pnpm-10.11.0.tgz; for troubleshooting help, see https://github.com/nodejs/corepack#troubleshooting

Expected behavior

The docker image should contain all the dependencies it needs to run.
Thus it should not download them at startup.
And this should allow it to run in an air-gapped environment, or behind a strong firewall.

App version

Splitpro 1.4.7 docker image (current latest)

Additional context

Full logs with network access

+ echo 'Deploying prisma migrations'
+ pnpx prisma@6 migrate deploy --schema ./prisma/schema.prisma
Deploying prisma migrations
Progress: resolved 1, reused 0, downloaded 0, added 0
Progress: resolved 2, reused 0, downloaded 1, added 0
Progress: resolved 11, reused 0, downloaded 6, added 0
Progress: resolved 22, reused 0, downloaded 14, added 0
Progress: resolved 47, reused 0, downloaded 34, added 0
Progress: resolved 50, reused 0, downloaded 48, added 0
Progress: resolved 52, reused 0, downloaded 48, added 0
Packages: +53
+++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 53, reused 0, downloaded 52, added 51
Progress: resolved 53, reused 0, downloaded 52, added 52
Progress: resolved 53, reused 0, downloaded 53, added 52
Progress: resolved 53, reused 0, downloaded 53, added 53, done
.../[email protected]/node_modules/prisma preinstall$ node scripts/preinstall-entry.js
.../[email protected]/node_modules/prisma preinstall: Done
warn The configuration property `package.json#prisma` is deprecated and will be removed in Prisma 7. Please migrate to a Prisma config file (e.g., `prisma.config.ts`).
For more information, see: https://pris.ly/prisma-config

Prisma schema loaded from prisma/schema.prisma
Error: Prisma schema validation - (get-config wasm)
Error code: P1012
error: Environment variable not found: DATABASE_URL.
  -->  prisma/schema.prisma:15
   |
14 |     // https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string
15 |     url      = env("DATABASE_URL")
   |

Validation Error Count: 1
[Context: getConfig]

Prisma CLI Version : 6.13.0
+ echo 'Starting web server'
+ node server.js
Starting web server
  ▲ Next.js 14.2.29
  - Local:        http://0a8aa2e4b1ad:3000
  - Network:      http://172.17.0.2:3000

 ✓ Starting...
Registering instrumentation
Validating auth env
 ✓ Ready in 1226ms

Full logs without network access

+ echo 'Deploying prisma migrations'
+ pnpx prisma@6 migrate deploy --schema ./prisma/schema.prisma
Deploying prisma migrations
/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:22051
    throw new Error(
          ^

Error: Error when performing the request to https://registry.npmjs.org/pnpm/-/pnpm-10.11.0.tgz; for troubleshooting help, see https://github.com/nodejs/corepack#troubleshooting
    at fetch (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:22051:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async fetchUrlStream (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:22081:20)
    ... 4 lines matching cause stack trace ...
    at async Object.runMain (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:23660:7) {
  [cause]: TypeError: fetch failed
      at node:internal/deps/undici/undici:13510:13
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
      at async fetch (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:22045:16)
      at async fetchUrlStream (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:22081:20)
      at async download (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:22208:18)
      at async installVersion (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:22300:55)
      at async Engine.ensurePackageManager (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:22851:32)
      at async Engine.executePackageManagerRequest (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:22962:25)
      at async Object.runMain (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:23660:7) {
    [cause]: Error: getaddrinfo EAI_AGAIN registry.npmjs.org
        at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:122:26) {
      errno: -3001,
      code: 'EAI_AGAIN',
      syscall: 'getaddrinfo',
      hostname: 'registry.npmjs.org'
    }
  }
}

Node.js v22.16.0
Starting web server
+ echo 'Starting web server'
+ node server.js
 ⨯ Failed to start server
Error: getaddrinfo EAI_AGAIN 1a87bff38f6b
    at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:122:26) {
  errno: -3001,
  code: 'EAI_AGAIN',
  syscall: 'getaddrinfo',
  hostname: '1a87bff38f6b'
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions