dockerkubernetesmonoreposkaffold

How to build docker image for monorepo with nextjs?


I use npm to build in Jenkins and in Skaffold :


build:
  artifacts:
    - image: containerregistry-ssss.net/container-sandbox/my-docs
      docker : dockerFile
      kaniko:
        buildContext:
          localDir: {}

In docker : the following folders are never found as two different projects exist under packages monorepo and only one of them need it but it's never created.


# Copy application to container's /app folder
WORKDIR /app
COPY .next/standalone ./.next/standalone
COPY .next/static ./.next/static
COPY public ./public

changed docker file location and relative path of the .next folders.


Solution

  • I had to add the 'context: packages/mydocs' in the skaffold.xml to point to mydocs folder. Also, npm ci and npm run build --workspace=mydocs command was added in jenkins. Changed the Kustomize folder location to point to mydocs folder.