Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/dstack/_internal/backend/base/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def get_dstack_runner() -> str:
build = version.__version__
else: # stgn
bucket = "dstack-runner-downloads-stgn"
build = version.__version__ or os.environ.get("DSTACK_RUNNER_BUILD", None)
build = version.__version__ or os.environ.get("DSTACK_RUNNER_VERSION", "latest")

commands = [
f'sudo curl --output /usr/local/bin/dstack-runner "https://{bucket}.s3.eu-west-1.amazonaws.com/{build}/binaries/dstack-runner-linux-amd64"',
Expand Down
1 change: 0 additions & 1 deletion cli/dstack/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
__version__ = None
__is_release__ = False
miniforge_image = "0.3"
runner_build = "latest"
12 changes: 10 additions & 2 deletions runner/internal/container/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ func (r *Engine) NewBuildSpec(ctx context.Context, job *models.Job, spec *Spec,
commands := append([]string{}, job.BuildCommands...)
commands = append(commands, job.OptionalBuildCommands...)
env := environment.New()
env.AddMapString(job.Environment)
env.AddMapString(secrets)

buildSpec := &BuildSpec{
Expand All @@ -321,7 +320,7 @@ func (r *Engine) NewBuildSpec(ctx context.Context, job *models.Job, spec *Spec,
WorkDir: spec.WorkDir,
ConfigurationPath: job.ConfigurationPath,
ConfigurationType: job.ConfigurationType,
Commands: ShellCommands(commands),
Commands: ShellCommands(InsertEnvs(commands, job.Environment)),
Entrypoint: spec.Entrypoint,
Env: env.ToSlice(),
RegistryAuthBase64: spec.RegistryAuthBase64,
Expand Down Expand Up @@ -453,6 +452,15 @@ func ShellCommands(commands []string) []string {
return []string{sb.String()}
}

// InsertEnvs allows interpolation of env variables (e.g. PATH=/foo/bar:$PATH)
func InsertEnvs(commands []string, envs map[string]string) []string {
output := make([]string, 0)
for name, val := range envs {
output = append(output, fmt.Sprintf("export %s=%s", name, val))
}
return append(output, commands...)
}

func BytesToMiB(bytesCount int64) uint64 {
var mib int64 = 1024 * 1024
return uint64(bytesCount / mib)
Expand Down
3 changes: 1 addition & 2 deletions runner/internal/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,6 @@ func (ex *Executor) environment(ctx context.Context, includeRun bool) []string {
env.AddMapString(job.RunEnvironment)
env.AddMapString(cons)
}
env.AddMapString(job.Environment)
secrets, err := ex.backend.Secrets(ctx)
if err != nil {
log.Error(ctx, "Fail fetching secrets", "err", err)
Expand Down Expand Up @@ -629,7 +628,7 @@ func (ex *Executor) newSpec(ctx context.Context, credPath string) (*container.Sp
Image: job.Image,
RegistryAuthBase64: makeRegistryAuthBase64(username, password),
WorkDir: path.Join("/workflow", job.WorkingDir),
Commands: container.ShellCommands(job.Commands),
Commands: container.ShellCommands(container.InsertEnvs(job.Commands, job.Environment)),
Entrypoint: job.Entrypoint,
Env: ex.environment(ctx, true),
Mounts: uniqueMount(bindings),
Expand Down