ignore folder/files from skaffold watch

2.3k views Asked by At

I am using the skaffold to run my typescript application with the helm in Kubernetes. Below is my skaffold build configuration.

apiVersion: skaffold/v2beta8
kind: Config
build:
  local: 
    push: false
  tagPolicy:
    gitCommit:
      variant: CommitSha
      prefix: commit-
  artifacts: 
  - image: my-app
    sync:
      infer: 
        - '**/**/*.ts'
        - '**/**/*.json' 

As per this, Whenever I start the application, the application sync my ts and JSON file when update, and other than these files, it will rebuild the app. I have a 'build' folder in my root-structure. which I have mounted on the Kubernetes pod so whenever the app builds I will get the latest build code at my local and it will help to debug the application. But due to this application continuously rebuilding as skaffold found the change in the build folder. So, How to ignore folder/file for skaffold watch? I tried to use buildpacks.dependencies but it won't be working (Giving error for builder image definition). Can anyone help me, please?

Thanks.

2

There are 2 answers

1
Brian de Alwis On BEST ANSWER

In your example, you're using Skaffold's docker builder. Skaffold's file watcher respects the values in the .dockerignore file.

0
Jevon Kendon On

For better or worse, I'm exploiting the manual sync option so that Skaffold does not perform a Docker build when a local file changes:

image: some-image
docker:
  dockerfile: Dockerfile
sync:
  manual:
    - src: 'some-file'
      dest: /some-directory-on-the-container

When some-file changes on the host (for whatever reason) Skaffold will copy that file to the running container and bypass a rebuild. I'm not concerned where it gets copied to on the running container.

Not what the mechanism is meant for, but it solves a problem. I actually need some-file on the first Docker build, so I couldn't put it in .dockerignore.

Skaffold Docs -> File Sync -> Manual sync mode