It seems the archive command automatically skips any folder called node_modules. Is there a way to configure this so that it does not skip these?
Hello @Marc_MacLeod,
Yes, we skip .git, node_modules and vendor directories. It’s defined here in he CLI
Why do you want to include it? It’s usually created during the build proces.
Ah, so might be easy to support overriding the hardcoded ignore defaults via an optional flag?
Good question re why . We’ve got a monorepo with many deployable artifacts inside of it. I’m building the apps w changes since last deploy in a GH action, and then using deploying the built app to koyeb from that GH action. This works well for everything except the frontend app, which uses Nitro under the hood (nuxt, tanstack start, solid start, and others use Nitro). Nitro includes a node_modules folder in the build .output (see screenshot below), with all of the relevant deps move and transformed etc. So ideally I’d like to just deploy this .output folder as-is, but can’t atm because the archive process ignores the node_modules folder.
Of course I could archive the entire monorepo and go through the yarn
+ yarn build
process for this app on the koyeb side, but that is much heavier since
- only a portion of the repo is relevant to deploy this frontend app
yarn
is expensive, and we’ve already run it within the GH action ci in order to run the tests, etc- building the frontend app is expensive, and we’ve already run this as well as part of our CI checks
What I’m doing for the time being is have a pre-depoloy script that recursively renames node_modules
to _node_modules
in the .output
folder. And then I’m deploying with a Dockerfile that does this :
FROM node:22.14.0-slim
WORKDIR /app
# NOTE everything is relative to the .output folder,
# since this is copied there by the deploy script, before uploading the archive
COPY . .
# Rename _node_modules back to node_modules, processing from deepest level first
# See this question: https://community.koyeb.com/t/can-i-include-node-modules-when-running-archive-create-or-deploy/3235
RUN find /app -type d -name "_node_modules" | sort -r | while read -r dir; do \
parent_dir=$(dirname "$dir"); \
mv "$dir" "$parent_dir/node_modules"; \
done
ARG PORT
EXPOSE ${PORT:-3000}
CMD ["node", "server/index.mjs"]
Ok, just for you Release v5.4.2 · koyeb/koyeb-cli · GitHub
Please update the CLI to the latest version and add --ignore-dir ""
to your koyeb archive create
command.
Pls let me know if it’s working as expected.
Hell yes! Thanks @Lukasz_Oles - gave it a go and it’s working great . Really appreciate it.