diff --git a/envbuilder.go b/envbuilder.go index 215ccc48..a16f2fb4 100644 --- a/envbuilder.go +++ b/envbuilder.go @@ -138,7 +138,7 @@ func Run(ctx context.Context, opts options.Options) error { if err != nil { return fmt.Errorf("git clone options: %w", err) } - cloneOpts.Path = constants.MagicRemoteRepoDir + cloneOpts.Path = opts.RemoteRepoDir endStage := startStage("📦 Remote repo build mode enabled, cloning %s to %s for build context...", newColor(color.FgCyan).Sprintf(opts.GitURL), @@ -912,7 +912,7 @@ func RunCacheProbe(ctx context.Context, opts options.Options) (v1.Image, error) if err != nil { return nil, fmt.Errorf("git clone options: %w", err) } - cloneOpts.Path = constants.MagicRemoteRepoDir + cloneOpts.Path = opts.RemoteRepoDir endStage := startStage("📦 Remote repo build mode enabled, cloning %s to %s for build context...", newColor(color.FgCyan).Sprintf(opts.GitURL), diff --git a/options/options.go b/options/options.go index ff6a8be3..d7bd66b3 100644 --- a/options/options.go +++ b/options/options.go @@ -7,6 +7,7 @@ import ( "os" "strings" + "github.com/coder/envbuilder/constants" "github.com/coder/envbuilder/log" "github.com/coder/serpent" "github.com/go-git/go-billy/v5" @@ -157,6 +158,10 @@ type Options struct { // working on the same repository. RemoteRepoBuildMode bool + // RemoteRepoDir is the destination directory for the cloned repo when using + // remote repo build mode. + RemoteRepoDir string + // BinaryPath is the path to the local envbuilder binary when // attempting to probe the build cache. This is only relevant when // GetCachedImage is true. @@ -450,6 +455,14 @@ func (o *Options) CLI() serpent.OptionSet { "be used to improving cache utilization when multiple users are building " + "working on the same repository.", }, + { + Flag: "remote-repo-dir", + Env: WithEnvPrefix("REMOTE_REPO_DIR"), + Value: serpent.StringOf(&o.RemoteRepoDir), + Default: constants.MagicRemoteRepoDir, + Hidden: true, + Description: "Specify the destination directory for the cloned repo when using remote repo build mode.", + }, { Flag: "verbose", Env: WithEnvPrefix("VERBOSE"),