diff --git a/pkg/commands/env.go b/pkg/commands/env.go index 6a3153ba8..ecab6f1d9 100644 --- a/pkg/commands/env.go +++ b/pkg/commands/env.go @@ -17,12 +17,12 @@ limitations under the License. package commands import ( + "strings" + "github.com/GoogleCloudPlatform/kaniko/pkg/util" "github.com/containers/image/manifest" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/sirupsen/logrus" - "os" - "strings" ) type EnvCommand struct { @@ -45,10 +45,6 @@ func (e *EnvCommand) ExecuteCommand(config *manifest.Schema2Config) error { Key: expandedKey, Value: expandedValue, } - logrus.Infof("Setting environment variable %s=%s", pair.Key, expandedValue) - if err := os.Setenv(pair.Key, expandedValue); err != nil { - return err - } } return updateConfigEnv(newEnvs, config) } diff --git a/pkg/commands/run.go b/pkg/commands/run.go index 6be8f33fe..f273d3d63 100644 --- a/pkg/commands/run.go +++ b/pkg/commands/run.go @@ -17,14 +17,15 @@ limitations under the License. package commands import ( - "github.com/containers/image/manifest" - "github.com/docker/docker/builder/dockerfile/instructions" - "github.com/sirupsen/logrus" "os" "os/exec" "strconv" "strings" "syscall" + + "github.com/containers/image/manifest" + "github.com/docker/docker/builder/dockerfile/instructions" + "github.com/sirupsen/logrus" ) type RunCommand struct { @@ -48,6 +49,8 @@ func (r *RunCommand) ExecuteCommand(config *manifest.Schema2Config) error { cmd := exec.Command(newCommand[0], newCommand[1:]...) cmd.Dir = config.WorkingDir cmd.Stdout = os.Stdout + cmd.Env = config.Env + // If specified, run the command as a specific user if config.User != "" { userAndGroup := strings.Split(config.User, ":")