loading...

Include files, rather than ignore

patarapolw profile image Pacharapol Withayasakpunt ・1 min read

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

Posted on Jun 4 by:

patarapolw profile

Pacharapol Withayasakpunt

@patarapolw

Currently interested in TypeScript, Vue, Kotlin and Python. Looking forward to learning DevOps, though.

Discussion

markdown guide
 

So you choose whitelist, instead of blacklist.

 

Just like package.json's "files": [] is much safer than .npmignore.