Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Docker build failure for node application Couldn't find the node_modules state file.

Amit Agrawal
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 9, 2024

I am buildimg a docker image, the dockerfile is

``` 

FROM node:18-bullseye-slim AS base

FROM base AS builder
WORKDIR /app
RUN yarn global add turbo
COPY . .
RUN --mount=type=cache,mode=0777,target=/app/.yarn/cache,id=api turbo prune --scope=api --docker

# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
WORKDIR /app

# First install dependencies (as they change less often)
COPY .gitignore .gitignore
COPY .yarnrc.build.yml .yarnrc.yml
COPY .yarn .yarn
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/yarn.lock ./yarn.lock
RUN --mount=type=cache,mode=0777,target=/app/.yarn/cache,id=api yarn install

# Build the project and its dependencies
COPY --from=builder /app/out/full/ .
COPY openapi ./openapi
COPY scripts ./scripts

RUN --mount=type=cache,mode=0777,target=/app/.yarn/cache,id=api yarn workspace @supaglue/db prisma generate
RUN --mount=type=cache,mode=0777,target=/app/.yarn/cache,id=api yarn workspace api ts-patch install -s
RUN --mount=type=cache,mode=0777,target=/app/.yarn/cache,id=api yarn turbo run build --filter=api...
RUN --mount=type=cache,mode=0777,target=/app/.yarn/cache,id=api yarn workspaces focus --production api
```
Having bitbucket pipeline:
```
image: node:18

pipelines:
  branches:
    ci_cd_setup:
      - step:
          name: Build and Push for master
          script:
            - apt update && apt-get install -y jq
            - corepack enable
            - directory=$(yarn workspaces list --json | jq -r 'select( .name == "api" ) | .location')
            - echo "export directory=$directory"
            - DOCKER_BUILDKIT=1 && export DOCKER_BUILDKIT=1 && env
            - docker build . --file ./apps/api/Dockerfile --tag api:latest --progress=plain --no-cache
            - docker images
          services:
            - docker
          caches:
             - docker

```

Giving error: 

Usage Error: Couldn't find the node_modules state file - running an install might help (findPackageLocation)

Please help out on how I can resolve this issue.

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events