You can see an example of configuring and using TypeScript and Yarn with Batect in the TypeScript sample project, and an example of using Cypress for UI testing with Batect in the Cypress sample project.
The Node.js bundle provides a container with all of these options pre-configured.
tl;dr: Mount a cache into your container for the
~/.cache/yarn directories, otherwise you'll experience poor performance on macOS and Windows.
Both NPM and Yarn download and store dependencies in the
node_modules directory in your application's directory. Yarn also caches downloaded dependencies in
However, when running on macOS and Windows, Docker exhibits poor I/O performance for directories mounted from the macOS or Windows host, as discussed in the section on
The solution to this is to mount a cache into your container for
Note that you can't use
~ in the container path for a volume mount:
- If you're using run as current user mode, use the home directory you specified for
- If you're not using run as current user mode, use
/rootas the home directory, as the vast majority of containers default to the root user and use this as the root user's home directory.
tl;dr: If signals such as
SIGINT (which is generated when you press Ctrl+C) aren't being handled correctly by your Node.js-based application,
enable_init_process for that container
Node.js does not behave correctly when it is running as process ID 1 (PID 1), which is what happens when running an application inside a container.
The most noticeable issue this causes is that applications do not respond correctly to signals such as
SIGINT (which is generated when you press Ctrl+C).
The solution is to run another process (an 'init process') as PID 1, which then runs your application and handles and forwards signals to it.
Docker has a slimmed-down init process built in that is designed for just this scenario. You can enable it for a container in Batect by setting
This article has a more detailed explanation of what is happening and why an init process solves this problem.