Skip to content

Commit

Permalink
fix: ignore node_modules for s2i builds (#1019)
Browse files Browse the repository at this point in the history
- 🎁 Exclude certain directories form S2I build tar know to be either unnecessary or error-prone
- 🐛  Error running Node Functions which unnecessarily had node_modules sent to the build daemon

Exclude various files and cache directories from S2I builds.  This list may need to be expanded in the future.
  • Loading branch information
lkingland authored May 26, 2022
1 parent dc8abf1 commit 1d367c6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions s2i/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ func (b *Builder) Build(ctx context.Context, f fn.Function) (err error) {
cfg.RuntimeImagePullPolicy = api.DefaultRuntimeImagePullPolicy
cfg.DockerConfig = s2idocker.GetDefaultDockerConfig()

// Excludes
// Do not include .git, .env, .func or any language-specific cache directories
// (node_modules, etc) in the tar file sent to the builder, as this both
// bloats the build process and can cause unexpected errors in the resultant
// Function.
cfg.ExcludeRegExp = "(^|/)\\.git|\\.env|\\.func|node_modules(/|$)"

// Environment variables
// Build Envs have local env var references interpolated then added to the
// config as an S2I EnvironmentList struct
Expand Down

0 comments on commit 1d367c6

Please sign in to comment.