PRISMA_SKIP_POSTINSTALL_GENERATE is Not Skipping Generate on yarn install

I am running into errors during dockerfile builds, in which I cannot reach the database. My soluition was to try using the environment variables. During yarn install it seems the generate command is still running.
4 Replies
Fright XO
Fright XOOP3mo ago
The docker file is failing on the last command in this snipper:
#############################################################
# Stage 2 - App installation #
#############################################################

FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS app-installer

# Optimize for YARN installation speed
ENV YARN_ENABLE_GLOBAL_CACHE=false
ENV YARN_ENABLE_MIRROR=false
ENV YARN_NODE_LINKER=node-modules
ENV YARN_NM_MODE=hardlinks-local
ENV YARN_ENABLE_HARDENED_MODE=0

# Disable the Prisma postinstall hook to avoid generating code early
ENV PRISMA_SKIP_POSTINSTALL_GENERATE=true
ENV PRISMA_GENERATE_SKIP_AUTOINSTALL=true
ENV DEBUG=prisma:postinstall

WORKDIR /app

# Copy gitignore and JSON files to get dependencies first, since they change less often.
COPY --link .gitignore ./
COPY --from=app-builder --link /app/out/data/json/ .

# Use a cached volume for Yarn and skip building dependencies to optimize caching
RUN --mount=type=cache,target=/root/.yarn3-cache,id=yarn3-cache \
YARN_CACHE_FOLDER=/root/.yarn3-cache \
yarn install --mode=skip-build

# Get the full pruned source for the data project.
COPY --from=app-builder /app/out/data/full/ .
COPY --link tsconfig.json ./

# Install and build all dependencies.
RUN --mount=type=cache,target=/root/.yarn3-cache,id=yarn3-cache \
YARN_CACHE_FOLDER=/root/.yarn3-cache \
yarn install --inline-builds
#############################################################
# Stage 2 - App installation #
#############################################################

FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS app-installer

# Optimize for YARN installation speed
ENV YARN_ENABLE_GLOBAL_CACHE=false
ENV YARN_ENABLE_MIRROR=false
ENV YARN_NODE_LINKER=node-modules
ENV YARN_NM_MODE=hardlinks-local
ENV YARN_ENABLE_HARDENED_MODE=0

# Disable the Prisma postinstall hook to avoid generating code early
ENV PRISMA_SKIP_POSTINSTALL_GENERATE=true
ENV PRISMA_GENERATE_SKIP_AUTOINSTALL=true
ENV DEBUG=prisma:postinstall

WORKDIR /app

# Copy gitignore and JSON files to get dependencies first, since they change less often.
COPY --link .gitignore ./
COPY --from=app-builder --link /app/out/data/json/ .

# Use a cached volume for Yarn and skip building dependencies to optimize caching
RUN --mount=type=cache,target=/root/.yarn3-cache,id=yarn3-cache \
YARN_CACHE_FOLDER=/root/.yarn3-cache \
yarn install --mode=skip-build

# Get the full pruned source for the data project.
COPY --from=app-builder /app/out/data/full/ .
COPY --link tsconfig.json ./

# Install and build all dependencies.
RUN --mount=type=cache,target=/root/.yarn3-cache,id=yarn3-cache \
YARN_CACHE_FOLDER=/root/.yarn3-cache \
yarn install --inline-builds
The following is what is output:
3.612 ➤ YN0000: └ Completed in 1s 658ms
3.713 ➤ YN0000: ┌ Link step
4.353 ➤ YN0007: │ @nestjs/core@npm:10.3.9 [53e0f] must be built because it never has been before or the last one failed
4.354 ➤ YN0007: │ @prisma/engines@npm:5.11.0 must be built because it never has been before or the last one failed
4.852 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT Thanks for installing nest
4.852 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT Please consider donating to our open collective
4.852 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT to help us maintain this package.
4.852 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT
4.852 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT Number of contributors: 0
4.852 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT Number of backers: 1067
4.896 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT Annual budget: $152,254
4.896 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT Current balance: $14,962
4.896 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT
4.905 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT Become a partner: https://opencollective.com/nest/donate
4.906 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT
5.057 ➤ YN0007: │ prisma@npm:5.11.0 must be built because it never has been before or the last one failed
5.225 ➤ YN0007: │ @prisma/client@npm:5.11.0 [6b952] must be built because it never has been before or the last one failed
5.328 ➤ YN0007: │ prisma-client@workspace:packages/prisma-client must be built because it never has been before or the last one failed
6.338 ➤ YN0000: │ prisma-client@workspace:packages/prisma-client STDOUT Environment variables loaded from .env
6.342 ➤ YN0000: │ prisma-client@workspace:packages/prisma-client STDOUT Prisma schema loaded from prisma/schema.prisma
6.384 ➤ YN0000: │ prisma-client@workspace:packages/prisma-client STDOUT Datasource "db": SQL Server database
6.384 ➤ YN0000: │ prisma-client@workspace:packages/prisma-client STDOUT
6.484 ➤ YN0000: │ prisma-client@workspace:packages/prisma-client STDERR Error: P1001: Can't reach database server at localhost:1433
6.484 ➤ YN0000: │ prisma-client@workspace:packages/prisma-client STDERR
6.484 ➤ YN0000: │ prisma-client@workspace:packages/prisma-client STDERR Please make sure your database server is running at localhost:1433. 1433`. p/xfs-63160ca8
6.630 ➤ YN0009: │ prisma-client@workspace:packages/prisma-client couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-63160ca8/build.log)
6.631 ➤ YN0000: └ Completed in 2s 917ms
6.733 ➤ YN0000: · Failed with errors in 5s 228ms
------ exit code: 1
failed to solve: process "/bin/sh -c YARN_CACHE_FOLDER=/root/.yarn3-cache yarn install" did not complete successfully: exit code: 1
3.612 ➤ YN0000: └ Completed in 1s 658ms
3.713 ➤ YN0000: ┌ Link step
4.353 ➤ YN0007: │ @nestjs/core@npm:10.3.9 [53e0f] must be built because it never has been before or the last one failed
4.354 ➤ YN0007: │ @prisma/engines@npm:5.11.0 must be built because it never has been before or the last one failed
4.852 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT Thanks for installing nest
4.852 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT Please consider donating to our open collective
4.852 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT to help us maintain this package.
4.852 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT
4.852 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT Number of contributors: 0
4.852 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT Number of backers: 1067
4.896 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT Annual budget: $152,254
4.896 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT Current balance: $14,962
4.896 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT
4.905 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT Become a partner: https://opencollective.com/nest/donate
4.906 ➤ YN0000: │ @nestjs/core@npm:10.3.9 [53e0f] STDOUT
5.057 ➤ YN0007: │ prisma@npm:5.11.0 must be built because it never has been before or the last one failed
5.225 ➤ YN0007: │ @prisma/client@npm:5.11.0 [6b952] must be built because it never has been before or the last one failed
5.328 ➤ YN0007: │ prisma-client@workspace:packages/prisma-client must be built because it never has been before or the last one failed
6.338 ➤ YN0000: │ prisma-client@workspace:packages/prisma-client STDOUT Environment variables loaded from .env
6.342 ➤ YN0000: │ prisma-client@workspace:packages/prisma-client STDOUT Prisma schema loaded from prisma/schema.prisma
6.384 ➤ YN0000: │ prisma-client@workspace:packages/prisma-client STDOUT Datasource "db": SQL Server database
6.384 ➤ YN0000: │ prisma-client@workspace:packages/prisma-client STDOUT
6.484 ➤ YN0000: │ prisma-client@workspace:packages/prisma-client STDERR Error: P1001: Can't reach database server at localhost:1433
6.484 ➤ YN0000: │ prisma-client@workspace:packages/prisma-client STDERR
6.484 ➤ YN0000: │ prisma-client@workspace:packages/prisma-client STDERR Please make sure your database server is running at localhost:1433. 1433`. p/xfs-63160ca8
6.630 ➤ YN0009: │ prisma-client@workspace:packages/prisma-client couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-63160ca8/build.log)
6.631 ➤ YN0000: └ Completed in 2s 917ms
6.733 ➤ YN0000: · Failed with errors in 5s 228ms
------ exit code: 1
failed to solve: process "/bin/sh -c YARN_CACHE_FOLDER=/root/.yarn3-cache yarn install" did not complete successfully: exit code: 1
Yetzederixx
Yetzederixx3mo ago
It can't see the database
6.484 ➤ YN0000: │ prisma-client@workspace:packages/prisma-client STDERR Please make sure your database server is running at localhost:1433. 1433`.
6.484 ➤ YN0000: │ prisma-client@workspace:packages/prisma-client STDERR Please make sure your database server is running at localhost:1433. 1433`.
Nurul
Nurul3mo ago
Does this issue happen only with yarn and not with npm? Is your database running on port 1433?
Please make sure your database server is running at localhost:1433.
Please make sure your database server is running at localhost:1433.
?
Yetzederixx
Yetzederixx3mo ago
How are you hosting the database? Docker, actual server on your rig, cloud?
Want results from more Discord servers?
Add your server