Create a dockerignore
template for Node.js/JavaScript projects
Source: R/dockerignore-templates.R
dk_template_ignore_node.Rd
Creates a dockerignore
template with patterns to ignore Node.js and
JavaScript related files and directories.
`
Details
This template adds patterns to ignore Node.js and JavaScript related files and directories, including:
node_modules/
: Package dependenciesnpm-debug.log*
,yarn-error.log*
: Package manager logspackage-lock.json
,yarn.lock
: Lock files.npm/
,.yarn/
: Cache directories*.tgz
: Packaged modules.pnp.*
: Plug'n'Play files.cache/
: Build cache.eslintcache
: ESLint cache
These files are typically not needed in a Docker image or can be regenerated
during the build process. Ignoring them can significantly reduce the build
context size, especially node_modules/
which can be very large.
See also
dk_template_ignore_python()
for Python-specific patterns &
dk_template_ignore_common()
for a more comprehensive template
Other dockerignore template functions:
dk_template_ignore_common()
,
dk_template_ignore_data()
,
dk_template_ignore_editor()
,
dk_template_ignore_git()
,
dk_template_ignore_os()
,
dk_template_ignore_packrat()
,
dk_template_ignore_python()
,
dk_template_ignore_r()
,
dk_template_ignore_raw_data()
,
dk_template_ignore_renv()
Examples
# Create a new dockerignore with Node.js patterns
di <- dk_template_ignore_node()
di
#> node_modules/
#> npm-debug.log*
#> yarn-error.log*
#> yarn-debug.log*
#> package-lock.json
#> yarn.lock
#> .npm/
#> .yarn/
#> *.tgz
#> .pnp.*
#> .cache/
#> .eslintcache
#> .node_repl_history
# Add Node.js patterns to an existing dockerignore
di <- dockerignore() |>
di_add("*.log") |>
dk_template_ignore_node()
di
#> *.log
#> node_modules/
#> npm-debug.log*
#> yarn-error.log*
#> yarn-debug.log*
#> package-lock.json
#> yarn.lock
#> .npm/
#> .yarn/
#> *.tgz
#> .pnp.*
#> .cache/
#> .eslintcache
#> .node_repl_history