diff --git a/cmd/deploy.go b/cmd/deploy.go index aa920b9b37..8df0d1f469 100644 --- a/cmd/deploy.go +++ b/cmd/deploy.go @@ -153,7 +153,7 @@ func (cmd *DeployCmd) Run(cobraCmd *cobra.Command, args []string) { // Print domain name if we use a cloud provider // TODO: Change this if cloud.DevSpaceURL != "" { - log.Infof("Your DevSpace is now reachable via ingress on this URL: http://%s", cloud.DevSpaceURL) + log.Infof("Your LiveSpace is now reachable via ingress on this URL: http://%s", cloud.DevSpaceURL) log.Info("See https://devspace-cloud.com/domain-guide for more information") } diff --git a/cmd/up.go b/cmd/up.go index e5e2f7921c..c59018e0bd 100644 --- a/cmd/up.go +++ b/cmd/up.go @@ -29,6 +29,7 @@ type UpCmdFlags struct { initRegistries bool build bool sync bool + terminal bool deploy bool exitAfterDeploy bool allyes bool @@ -50,6 +51,7 @@ var UpFlagsDefault = &UpCmdFlags{ initRegistries: true, build: false, sync: true, + terminal: true, switchContext: false, exitAfterDeploy: false, allyes: false, @@ -90,6 +92,7 @@ Starts and connects your DevSpace: cobraCmd.Flags().BoolVar(&cmd.flags.sync, "sync", cmd.flags.sync, "Enable code synchronization") cobraCmd.Flags().BoolVar(&cmd.flags.verboseSync, "verbose-sync", cmd.flags.verboseSync, "When enabled the sync will log every file change") cobraCmd.Flags().BoolVar(&cmd.flags.portforwarding, "portforwarding", cmd.flags.portforwarding, "Enable port forwarding") + cobraCmd.Flags().BoolVar(&cmd.flags.terminal, "terminal", cmd.flags.terminal, "Enable terminal") cobraCmd.Flags().BoolVarP(&cmd.flags.deploy, "deploy", "d", cmd.flags.deploy, "Force chart deployment") cobraCmd.Flags().BoolVar(&cmd.flags.switchContext, "switch-context", cmd.flags.switchContext, "Switch kubectl context to the devspace context") cobraCmd.Flags().BoolVar(&cmd.flags.exitAfterDeploy, "exit-after-deploy", cmd.flags.exitAfterDeploy, "Exits the command after building the images and deploying the devspace") @@ -251,5 +254,15 @@ func startServices(flags *UpCmdFlags, kubectl *kubernetes.Clientset, args []stri log.Info("See https://devspace-cloud.com/domain-guide for more information") } - return services.StartTerminal(kubectl, flags.service, flags.container, flags.labelSelector, flags.namespace, args, log) + config := configutil.GetConfig() + + if flags.terminal && (config.DevSpace == nil || config.DevSpace.Terminal == nil || config.DevSpace.Terminal.Disabled == nil || *config.DevSpace.Terminal.Disabled == false) { + return services.StartTerminal(kubectl, flags.service, flags.container, flags.labelSelector, flags.namespace, args, log) + } else if config.DevSpace != nil && ((flags.portforwarding && config.DevSpace.Ports != nil && len(*config.DevSpace.Ports) > 0) || (flags.sync && config.DevSpace.Sync != nil && len(*config.DevSpace.Sync) > 0)) { + log.Done("Services started (Press Ctrl+C to abort port-forwarding and sync)") + + <-make(chan bool) + } + + return nil } diff --git a/docs/docs/configuration/config.yaml.md b/docs/docs/configuration/config.yaml.md index b07d48a3ac..ffe5771c92 100644 --- a/docs/docs/configuration/config.yaml.md +++ b/docs/docs/configuration/config.yaml.md @@ -71,6 +71,7 @@ These services can be referenced within other config options (e.g. terminal, por ### devspace.terminal In this section options are defined, what should happen when devspace up or devspace enter try to open a terminal. By default, devspace will select pods with the labels `release=devspace-default` and try to start a bash or sh terminal in the container. +- `disabled` *bool* if true no terminal will be opened on `devspace up` and `devspace enter` - `service` *string* DevSpace service to start the terminal for (use either service OR namespace, labelSelector, containerName) - `namespace` *string* the namespace where to select pods from - `labelSelector` *map[string]string* a key value map with the labels to select the correct pod (default: release: devspace-default) @@ -217,6 +218,9 @@ devSpace: resourceType: pod # terminal options for devspace up and devspace enter terminal: + # if you don't want devspace to automatically open a terminal for + # you set disabled to true + disabled: false # define the service to start the terminal for service: default # Alternative to using a service is to diff --git a/pkg/devspace/builder/docker/docker.go b/pkg/devspace/builder/docker/docker.go index 59a0f69c93..085b81d786 100644 --- a/pkg/devspace/builder/docker/docker.go +++ b/pkg/devspace/builder/docker/docker.go @@ -4,6 +4,9 @@ import ( "context" "encoding/base64" "encoding/json" + "os" + "path/filepath" + "strings" dockerclient "github.com/covexo/devspace/pkg/devspace/docker" @@ -84,6 +87,18 @@ func (b *Builder) BuildImage(contextPath, dockerfilePath string, options *types. return err } + var dockerfileCtx *os.File + + // Dockerfile is out of context + if err == nil && strings.HasPrefix(relDockerfile, ".."+string(filepath.Separator)) { + // Dockerfile is outside of build-context; read the Dockerfile and pass it as dockerfileCtx + dockerfileCtx, err = os.Open(dockerfilePath) + if err != nil { + return errors.Errorf("unable to open Dockerfile: %v", err) + } + defer dockerfileCtx.Close() + } + excludes, err := build.ReadDockerignore(contextDir) if err != nil { return err @@ -109,6 +124,14 @@ func (b *Builder) BuildImage(contextPath, dockerfilePath string, options *types. return err } + // replace Dockerfile if it was added from stdin or a file outside the build-context, and there is archive context + if dockerfileCtx != nil && buildCtx != nil { + buildCtx, relDockerfile, err = build.AddDockerfileToBuildContext(dockerfileCtx, buildCtx) + if err != nil { + return err + } + } + // Setup an upload progress bar progressOutput := streamformatter.NewProgressOutput(outStream) body := progress.NewProgressReader(buildCtx, progressOutput, 0, "", "Sending build context to Docker daemon") diff --git a/pkg/devspace/config/v1/terminal.go b/pkg/devspace/config/v1/terminal.go index 936bd8babf..9af28966a8 100644 --- a/pkg/devspace/config/v1/terminal.go +++ b/pkg/devspace/config/v1/terminal.go @@ -2,6 +2,7 @@ package v1 // Terminal describes the terminal options type Terminal struct { + Disabled *bool `yaml:"disabled,omitempty"` Service *string `yaml:"service,omitempty"` ResourceType *string `yaml:"resourceType"` LabelSelector *map[string]*string `yaml:"labelSelector"` diff --git a/pkg/devspace/configure/registry.go b/pkg/devspace/configure/registry.go index 64e5766114..3dd4c33ad7 100644 --- a/pkg/devspace/configure/registry.go +++ b/pkg/devspace/configure/registry.go @@ -106,7 +106,7 @@ func Image(dockerUsername string, skipQuestions bool, registryURL, defaultImageN createPullSecret = createPullSecret || *stdinutil.GetFromStdin(&stdinutil.GetFromStdinParams{ Question: "Do you want to enable automatic creation of pull secrets for this image? (yes | no)", - DefaultValue: "no", + DefaultValue: "yes", ValidationRegexPattern: "^(yes|no)$", }) == "yes" } diff --git a/pkg/devspace/services/terminal.go b/pkg/devspace/services/terminal.go index e3df680027..1120b0005e 100644 --- a/pkg/devspace/services/terminal.go +++ b/pkg/devspace/services/terminal.go @@ -99,7 +99,7 @@ func StartTerminal(client *kubernetes.Clientset, serviceNameOverride, containerN pod, err := kubectl.GetNewestRunningPod(client, labelSelector, namespace) log.StopWait() if err != nil { - return fmt.Errorf("Cannot find running pod: %v", err) + return fmt.Errorf("Error starting terminal: Cannot find running pod: %v", err) } // Get container name