Skip to content

Commit

Permalink
add experimental feature to enable zstd for depot builds
Browse files Browse the repository at this point in the history
  • Loading branch information
jipperinbham committed Nov 15, 2024
1 parent 3ecc509 commit e490e05
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/appconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ type Experimental struct {
LazyLoadImages bool `toml:"lazy_load_images,omitempty" json:"lazy_load_images,omitempty"`
Attached Attached `toml:"attached,omitempty" json:"attached,omitempty"`
MachineConfig string `toml:"machine_config,omitempty" json:"machine_config,omitempty"`
UseZstd bool `toml:"use_zstd,omitempty" json:"use_zstd,omitempty"`
}

type Attached struct {
Expand Down
2 changes: 2 additions & 0 deletions internal/build/imgsrc/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type ImageOptions struct {
BuildpacksDockerHost string
BuildpacksVolumes []string
UseOverlaybd bool
UseZstd bool
}

func (io ImageOptions) ToSpanAttributes() []attribute.KeyValue {
Expand All @@ -72,6 +73,7 @@ func (io ImageOptions) ToSpanAttributes() []attribute.KeyValue {
attribute.String("imageoptions.buildpacks_docker_host", io.BuildpacksDockerHost),
attribute.StringSlice("imageoptions.buildpacks", io.Buildpacks),
attribute.StringSlice("imageoptions.buildpacks_volumes", io.BuildpacksVolumes),
attribute.Bool("imageoptions.use_zstd", io.UseZstd),
}

if io.BuildArgs != nil {
Expand Down
8 changes: 8 additions & 0 deletions internal/command/command_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ func DetermineImage(ctx context.Context, appName string, imageOrPath string) (im
}
opts.BuildArgs = extraArgs

if cfg != nil && cfg.Experimental != nil {
opts.UseZstd = cfg.Experimental.UseZstd
}
// use-zstd passed through flags takes precedence over the one set in config
if useZstd := flag.GetBool(ctx, "use-zstd"); useZstd {
opts.UseZstd = useZstd
}

img, err = resolver.BuildImage(ctx, io, opts)
if err != nil {
return nil, err
Expand Down
2 changes: 2 additions & 0 deletions internal/command/deploy/deploy_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ func determineImage(ctx context.Context, appConfig *appconfig.Config, useWG, rec

if appConfig.Experimental != nil {
opts.UseOverlaybd = appConfig.Experimental.LazyLoadImages

opts.UseZstd = appConfig.Experimental.UseZstd
}

// flyctl supports key=value form while Docker supports id=key,src=/path/to/secret form.
Expand Down

0 comments on commit e490e05

Please sign in to comment.