turbo
turbo copied to clipboard
Prune does not respect .gitignore files inside packages
What version of Turborepo are you using?
1.2.12
What package manager are you using / does the bug impact?
Yarn v1
What operating system are you using?
Mac
Describe the Bug
When running a prune command to prepare folders for docker, those folders include files that are ignored by the .gitignore
inside packages as well as at the root of the monorepo. One such example would be node_modules
folder that gets copied to generated out/full
folder with the following command:
yarn turbo prune --docker --scope="api-service"
Expected Behavior
I would expect prune to copy only files that are not ignored by git. (Or something like .turboignore
)
To Reproduce
Run command specified above to generate pruned version.
It's weird that there's no support for ignoring files/directories.
.env
type files would be another example of files that would often be a mistake to carry over
@chris-olszewski do you know if there were any changes to this in the last year?
Anyone found a solution for this?
We talked about this at the team meeting and decided that we should do this! Feel free to make a PR or even a failing test case!
Anyone found a solution for this?
I've used several different approaches. Here's one really ugly workaround I'm using in one case. After running turbo prune --docker ...
, I run this command:
(cd out/full && git init . && git add . && git clean -fdX && rm -rf .git)
Another one is to first have git make a copy of the local repo (git clone $PATH_TO_SRC $PATH_TO_DST
), and run turbo prune
in that. The behavior here is a bit different than the above, insofar as git clone
will only copy over committed files, so if you want turbo prune
to include untracked or modified files, you'll need to commit them first.
Another approach I've used is to run turbo prune
inside a nix flake build target, which automatically only uses your git files. But I'm not happy with that approach either because nix using a lot of extra disk storage that you need to regularly clear.
Lastly, I've used a Dockerfile to build the pruned output, where you can try to put your .gitignore contents into .dockerignore. I found three drawbacks: a) this doesn't fully work if you have special .gitignore files in subfolders, b) you need to copy the results back out of the docker image, which is a pain, c) you need to keep on top of deleting the images.