In short, the syntax for .dockerignore
, which is more restrictive than .gitignore
is
# Ignore everything
**
# Allow files and directories
!/file.txt
!/src/**
# Ignore unnecessary files inside allowed directories
# This should go after the allowed directories
**/*~
**/*.log
**/.DS_Store
**/Thumbs.db
So, my current .dockerignore
is
# Ignore everything
**
# Allow files and directories
!/packages/server/src
!/packages/server/package.json
!/packages/server/yarn.lock
!/packages/server/tsconfig.json
!/packages/web/public
!/packages/web/src
!/packages/web/.browserslistrc
!/packages/web/babel.config.js
!/packages/web/package.json
!/packages/web/yarn.lock
!/packages/web/tsconfig.json
!/packages/web/vue.config.js
.eslintignore
is much closer to .gitignore
, but I am not sure about nesting, which obviously, .gitignore
can do.
*.*
!*.js
!*.jsx
!*.ts
!*.tsx
!*.vue
node_modules
dist
lib
Top comments (2)
So you choose whitelist, instead of blacklist.
Just like
package.json
's"files": []
is much safer than.npmignore
.