diff --git a/cmd/init.go b/cmd/init.go index 0897db8376..898139b35d 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -396,7 +396,6 @@ func (cmd *InitCmd) addDefaultSyncConfig() { func (cmd *InitCmd) configureRegistry() { dockerUsername := "" - createInternalRegistryDefaultAnswer := "yes" imageBuilder, err := docker.NewBuilder("", "", "", false) if err == nil { @@ -406,9 +405,6 @@ func (cmd *InitCmd) configureRegistry() { if err == nil { dockerUsername = dockerAuthConfig.Username - if dockerUsername != "" { - createInternalRegistryDefaultAnswer = "no" - } } } else { // Set default build engine to kaniko, if no docker is installed @@ -420,26 +416,10 @@ func (cmd *InitCmd) configureRegistry() { } } - // Only deploy registry in minikube + // Don't push image in minikube if kubectl.IsMinikube() { - createInternalRegistry := cmd.flags.skipQuestions || cmd.flags.createInternalRegistry - if !createInternalRegistry { - createInternalRegistryAnswer := stdinutil.GetFromStdin(&stdinutil.GetFromStdinParams{ - Question: "Should we create a private registry within your Kubernetes cluster for you? (yes | no)", - DefaultValue: createInternalRegistryDefaultAnswer, - ValidationRegexPattern: "^(yes)|(no)$", - }) - createInternalRegistry = *createInternalRegistryAnswer == "yes" - } - - if createInternalRegistry { - err := configure.InternalRegistry() - if err != nil { - log.Fatal(err) - } - - return - } + cmd.defaultImage.SkipPush = configutil.Bool(true) + return } err = configure.Image(dockerUsername, cmd.flags.skipQuestions, cmd.flags.registryURL, cmd.flags.defaultImageName, cmd.flags.createPullSecret) diff --git a/docs/docs/configuration/config.yaml.md b/docs/docs/configuration/config.yaml.md index 82c1bfcf5a..a6756eb4fc 100644 --- a/docs/docs/configuration/config.yaml.md +++ b/docs/docs/configuration/config.yaml.md @@ -100,6 +100,7 @@ An image is defined by: - `name` *string* name of the image with registry url prefixed (e.g. dockerhubname/image, gcr.io/googleprojectname/image etc.) - `createPullSecret` *bool* creates a pull secret in the cluster namespace if the credentials are available in the docker credentials store or specified under `registries[].auth` - `registry` *string* Optional: registry references one of the keys defined in the `registries` map. If defined do not prefix the image name with the registry url +- `skipPush` *bool* if true the image push step is skipped for this image (useful for minikube setups see [minikube-example](https://github.com/covexo/devspace/tree/master/examples/minikube)) - `build` *BuildConfig* defines the build procedure for this image ### images[].build diff --git a/examples/minikube/.devspace/config.yaml b/examples/minikube/.devspace/config.yaml index fcca4dfffb..7872c55f4a 100755 --- a/examples/minikube/.devspace/config.yaml +++ b/examples/minikube/.devspace/config.yaml @@ -26,7 +26,4 @@ devSpace: images: default: name: devspace - createPullSecret: true - registry: internal -internalRegistry: - deploy: true + skipPush: true diff --git a/examples/minikube/.devspace/overwrite.yaml b/examples/minikube/.devspace/overwrite.yaml deleted file mode 100755 index d7838b140f..0000000000 --- a/examples/minikube/.devspace/overwrite.yaml +++ /dev/null @@ -1,5 +0,0 @@ -registries: - internal: - auth: - password: 58prtrR8tjNS - username: user-7IS6l diff --git a/examples/minikube/README.md b/examples/minikube/README.md index 2ef26e4302..b31b555b1a 100644 --- a/examples/minikube/README.md +++ b/examples/minikube/README.md @@ -11,60 +11,46 @@ In order to use this example, make sure you have a working minikube setup (you d To deploy the application to minikube simply run `devspace up`. The output of the command should look similar to this: ``` -[DONE] √ Tiller started -[DONE] √ Internal registry started +[INFO] Create namespace test [INFO] Building image 'devspace' with engine 'docker' -[DONE] √ Authentication successful (10.102.46.101:5000) -Sending build context to Docker daemon 6.144kB -Step 1/7 : FROM node:8.11.4 +[DONE] √ Authentication successful (hub.docker.com) +Sending build context to Docker daemon 7.077MB +Step 1/8 : FROM node:8.11.4 ---> 8198006b2b57 -Step 2/7 : RUN mkdir /app +Step 2/8 : RUN mkdir /app ---> Using cache - ---> 1b6632b2da50 -Step 3/7 : WORKDIR /app + ---> be8130ce594c +Step 3/8 : WORKDIR /app ---> Using cache - ---> 20b4e5a1df9b -Step 4/7 : COPY package.json . - ---> ee7f6e81e51d -Step 5/7 : RUN npm install - ---> Running in e6ef4c082b0c -npm notice created a lockfile as package-lock.json. You should commit this file. -npm WARN node-js-sample@0.0.1 No repository field. - -added 48 packages in 1.946s - ---> ff5be7678a3d -Step 6/7 : COPY . . - ---> b20037e9623f -Step 7/7 : CMD ["npm", "start"] - ---> Running in abd0c9294587 - ---> f8d49e9378ff -Successfully built f8d49e9378ff -Successfully tagged 10.102.46.101:5000/devspace:oswQSfh -The push refers to repository [10.102.46.101:5000/devspace] -e4f99e03005a: Pushed -c9515cc05f90: Pushed -9ad0fa9ab2ad: Pushed -10959d10898a: Pushed -be0fb77bfb1f: Pushed -63c810287aa2: Pushed -2793dc0607dd: Pushed -74800c25aa8c: Pushed -ba504a540674: Pushed -81101ce649d5: Pushed -daf45b2cad9a: Pushed -8c466bf4ca6f: Pushed -oswQSfh: digest: sha256:af6f6f701136149dc303aad52c124ab8913015e8125ae68994e06325c327cc2e size: 2839 -[INFO] Image pushed to registry (10.102.46.101:5000) + ---> a66cd053d094 +Step 4/8 : COPY package.json . + ---> Using cache + ---> e84f0c80a89d +Step 5/8 : RUN npm install + ---> Using cache + ---> b972ec2c40f8 +Step 6/8 : COPY . . + ---> 867b7c08b0f4 +Step 7/8 : EXPOSE 3000 + ---> Running in 50767081a2b8 + ---> e43d3516a051 +Step 8/8 : CMD ["npm", "start"] + ---> Running in 974c711c9c81 + ---> 687b0db6e4d5 +Successfully built 687b0db6e4d5 +Successfully tagged devspace:amodlCX +[INFO] Skip image push for devspace [DONE] √ Done building and pushing image 'devspace' [INFO] Deploying devspace-default with helm +[DONE] √ Tiller started [DONE] √ Deployed helm chart (Release revision: 1) -[DONE] √ Successfully deployed devspace-default +[DONE] √ Finished deploying devspace-default [DONE] √ Port forwarding started on 3000:3000 [DONE] √ Sync started on /go-workspace/src/github.com/covexo/devspace/examples/minikube <-> /app (Pod: test/devspace-default-6446cb6b8c-c2l2q) root@devspace-default-6446cb6b8c-c2l2q:/app# ``` -The command deployed a tiller server and internal registry and used the minikube docker daemon to build the dockerfile. +The command deployed a tiller server and used the minikube docker daemon to build the dockerfile. Furthermore a bi-directional sync was started between the local folder `/go-workspace/src/github.com/covexo/devspace/examples/minikube` and `/app` within the docker container. Whenever you change a file in either of those two folders the change will be synchronized. In addition the container port 3000 was forwarded to your local port 3000. diff --git a/examples/offline-development/.devspace/config.yaml b/examples/offline-development/.devspace/config.yaml index 9b172b5b69..7872c55f4a 100755 --- a/examples/offline-development/.devspace/config.yaml +++ b/examples/offline-development/.devspace/config.yaml @@ -26,7 +26,4 @@ devSpace: images: default: name: devspace - registry: internal - createPullSecret: true -internalRegistry: - deploy: true + skipPush: true diff --git a/examples/offline-development/.devspace/overwrite.yaml b/examples/offline-development/.devspace/overwrite.yaml deleted file mode 100755 index d7838b140f..0000000000 --- a/examples/offline-development/.devspace/overwrite.yaml +++ /dev/null @@ -1,5 +0,0 @@ -registries: - internal: - auth: - password: 58prtrR8tjNS - username: user-7IS6l diff --git a/examples/offline-development/README.md b/examples/offline-development/README.md index 53bea070a7..81de12df28 100644 --- a/examples/offline-development/README.md +++ b/examples/offline-development/README.md @@ -11,60 +11,46 @@ In order to use this example, make sure you have a working minikube setup (you d This step has to be done once while being online. To deploy the application to minikube simply run `devspace up`. The output of the command should look similar to this: ``` -[DONE] √ Tiller started -[DONE] √ Internal registry started +[INFO] Create namespace test [INFO] Building image 'devspace' with engine 'docker' -[DONE] √ Authentication successful (10.102.46.101:5000) -Sending build context to Docker daemon 6.144kB -Step 1/7 : FROM node:8.11.4 +[DONE] √ Authentication successful (hub.docker.com) +Sending build context to Docker daemon 7.077MB +Step 1/8 : FROM node:8.11.4 ---> 8198006b2b57 -Step 2/7 : RUN mkdir /app +Step 2/8 : RUN mkdir /app ---> Using cache - ---> 1b6632b2da50 -Step 3/7 : WORKDIR /app + ---> be8130ce594c +Step 3/8 : WORKDIR /app ---> Using cache - ---> 20b4e5a1df9b -Step 4/7 : COPY package.json . - ---> ee7f6e81e51d -Step 5/7 : RUN npm install - ---> Running in e6ef4c082b0c -npm notice created a lockfile as package-lock.json. You should commit this file. -npm WARN node-js-sample@0.0.1 No repository field. - -added 48 packages in 1.946s - ---> ff5be7678a3d -Step 6/7 : COPY . . - ---> b20037e9623f -Step 7/7 : CMD ["npm", "start"] - ---> Running in abd0c9294587 - ---> f8d49e9378ff -Successfully built f8d49e9378ff -Successfully tagged 10.102.46.101:5000/devspace:oswQSfh -The push refers to repository [10.102.46.101:5000/devspace] -e4f99e03005a: Pushed -c9515cc05f90: Pushed -9ad0fa9ab2ad: Pushed -10959d10898a: Pushed -be0fb77bfb1f: Pushed -63c810287aa2: Pushed -2793dc0607dd: Pushed -74800c25aa8c: Pushed -ba504a540674: Pushed -81101ce649d5: Pushed -daf45b2cad9a: Pushed -8c466bf4ca6f: Pushed -oswQSfh: digest: sha256:af6f6f701136149dc303aad52c124ab8913015e8125ae68994e06325c327cc2e size: 2839 -[INFO] Image pushed to registry (10.102.46.101:5000) + ---> a66cd053d094 +Step 4/8 : COPY package.json . + ---> Using cache + ---> e84f0c80a89d +Step 5/8 : RUN npm install + ---> Using cache + ---> b972ec2c40f8 +Step 6/8 : COPY . . + ---> 867b7c08b0f4 +Step 7/8 : EXPOSE 3000 + ---> Running in 50767081a2b8 + ---> e43d3516a051 +Step 8/8 : CMD ["npm", "start"] + ---> Running in 974c711c9c81 + ---> 687b0db6e4d5 +Successfully built 687b0db6e4d5 +Successfully tagged devspace:amodlCX +[INFO] Skip image push for devspace [DONE] √ Done building and pushing image 'devspace' [INFO] Deploying devspace-default with helm +[DONE] √ Tiller started [DONE] √ Deployed helm chart (Release revision: 1) -[DONE] √ Successfully deployed devspace-default +[DONE] √ Finished deploying devspace-default [DONE] √ Port forwarding started on 3000:3000 [DONE] √ Sync started on /go-workspace/src/github.com/covexo/devspace/examples/offline-development <-> /app (Pod: test/devspace-default-6446cb6b8c-c2l2q) root@devspace-default-6446cb6b8c-c2l2q:/app# ``` -The command deployed a tiller server, internal registry and used the minikube docker daemon to build the dockerfile. +The command deployed a tiller server and used the minikube docker daemon to build the dockerfile. Furthermore a bi-directional sync was started between the local folder `/go-workspace/src/github.com/covexo/devspace/examples/offline-development` and `/app` within the docker container. Whenever you change a file in either of those two folders the change will be synchronized. In addition the container port 3000 was forwarded to your local port 3000. diff --git a/pkg/devspace/config/v1/image.go b/pkg/devspace/config/v1/image.go index 8e1eeb282e..90218ea4c0 100644 --- a/pkg/devspace/config/v1/image.go +++ b/pkg/devspace/config/v1/image.go @@ -6,6 +6,7 @@ type ImageConfig struct { Tag *string `yaml:"tag"` Registry *string `yaml:"registry"` CreatePullSecret *bool `yaml:"createPullSecret,omitempty"` + SkipPush *bool `yaml:"skipPush"` Build *BuildConfig `yaml:"build"` } diff --git a/pkg/devspace/image/build.go b/pkg/devspace/image/build.go index 3aee5bc9b4..e20bcf0191 100644 --- a/pkg/devspace/image/build.go +++ b/pkg/devspace/image/build.go @@ -177,12 +177,16 @@ func Build(client *kubernetes.Clientset, generatedConfig *generated.Config, imag return false, fmt.Errorf("Error during image build: %v", err) } - err = imageBuilder.PushImage() - if err != nil { - return false, fmt.Errorf("Error during image push: %v", err) - } + if imageConf.SkipPush == nil || *imageConf.SkipPush == false { + err = imageBuilder.PushImage() + if err != nil { + return false, fmt.Errorf("Error during image push: %v", err) + } - log.Info("Image pushed to registry (" + displayRegistryURL + ")") + log.Info("Image pushed to registry (" + displayRegistryURL + ")") + } else { + log.Infof("Skip image push for %s", imageName) + } // Update config if *registryConf.URL != "" { @@ -192,6 +196,7 @@ func Build(client *kubernetes.Clientset, generatedConfig *generated.Config, imag generatedConfig.ImageTags[imageName] = imageTag log.Done("Done building and pushing image '" + imageName + "'") + } else { log.Infof("Skip building image '%s'", imageName) }