Start your first DevSpace and
build a simple web application in less than 5 minutes.
Install the DevSpace CLI
You can install the DevSpace CLI with the following scripts:
Make sure you are ADMIN!1 [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12'2 md -Force "$Env:Programfiles\devspace"3 wget -UseBasicParsing ((Invoke-WebRequest -URI "https://api.github.com/repos/covexo/devspace/releases/latest" -UseBasicParsing).Content -replace ".*`"(https://github.com[^`"]*devspace-windows-amd64.exe)`".*","`$1") -o $Env:Programfiles\devspace\devspace.exe4 & "$Env:Programfiles\devspace\devspace.exe" "install"COPY
As an alternative to the installer scripts, you can simply download the binary for your platform from the GitHub Releases page and add the binary to your PATH.
For Linux, Mac and Windows 10 Pro: Follow this link to download and install the Docker Community Edition.
For Windows 10 Home and others: Follow this link to download and install the Docker Toolbox.
If you already have Docker installed, just continue with the next step.
After installing Docker, make sure you are logged in to Docker Hub with this command:
1 docker loginCOPY
If you do not have a Docker Hub account, follow this link to sign up for Docker Hub.
Checkout the Demo Project
To show you how to start a DevSpace, clone our demo app with this command:
1 git clone https://github.com/covexo/devspace-quickstart-nodejs2 cd devspace-quickstart-nodejsCOPY
This project contains a mininal webserver with a “Hello World” application. It is only used to demonstrate how the DevSpace CLI works in this quickstart guide. Generally, the DevSpace CLI works with any programming language and can be used with any existing project.
Start the DevSpace
Run devspace up to start a DevSpace for the demo project:
1 devspace upCOPY
When running devspace up for the first time, the DevSpace CLI will automatically create a configuration for your DevSpace. There are a couple of basic questions that you need to answer during this process:
For the demo app, just confirm the suggested language with ENTER.
If your programming language is not listed as supported language, just choose none. This will create a basic Dockerfile for you, which you should customize later on.
The next question asks if you want to use the DevSpace Cloud or your own Kubernetes cluster. To get started quickly, choose to use the DevSpace Cloud and confirm with ENTER.
1 Do you want to use the DevSpace Cloud? (free, ready-to-use Kubernetes)2 > yesCOPY
After choosing the DevSpace Cloud, a browser window will open and show the login for the DevSpace Cloud. Currently, we only support GitHub as login method. Click on Login with GitHub and confirm your login with Authorize covexo.
Using the DevSpace Cloud is optional. The DevSpace CLI works with every Kubernetes cluster (cloud, self-hosted, minikube).
Optionally, you can now add the DevSpace Cloud as Kubernetes context. Adding the DevSpace Cloud to your ./kube/config file allows you to run kubectl commands within your Kubernetes namespace provided by the DevSpace Cloud.
1 Do you want to add the DevSpace Cloud to the $HOME/.kube/config file?2 > yesCOPY
For this quickstart guide, we want to use Docker Hub as our image registry.
1 Which registry do you want to push to? (‘hub.docker.com’ or URL)2 > hub.docker.comCOPY
The DevSpace CLI can push to any Docker registry (public and private). If you want to know more about pushing images to a private registry, take a look at our docs page for using private registries.
When using Docker Hub, the DevSpace CLI tries to detect your Docker username and suggest a name for your image accordingly:
1 Which image name to you want to use on Docker Hub?2 > [your-docker-username]/devspaceCOPY
Make sure you have the permission to push this image to Docker Hub and confirm with ENTER.
1 Do you want to create a pull secret automatically for this image?2 > yesCOPY
When Kubernetes pulls a private image from a registry, it needs an image pull secret. The DevSpace CLI can automatically create such a secret for you. Choose yes if you plan to make your image private or create an image pull secret manually within your DevSpace Cloud namespace.
Code within the DevSpace
After running devspace up and starting your DevSpace, the DevSpace CLI will initialize a terminal session for you. Every command you run within this terminal will directly be executed within a container of your DevSpace. To start our demo application, run the following command within the DevSpace terminal:
1 npm run devCOPY
This will start a small web server which listens on port 3000 within your DevSpace. Because the DevSpace CLI automatically added a port-forwarding config for the EXPOSE 3000 statement in the Dockerfile of the demo app, you can now open http://localhost:3000/ within your browser and directly access your demo application.
If you want to open a second terminal session in parallel, use the command devspace enter. Because most applications need more than one container, you can also change your default terminal container or use devspace enter -c [container-name].
Our demo application uses a hot reloading tool and is configured to reload the web server whenever you change a file. So, let’s take a look at the following file:
/index.js1 const express = require('express')2 const app = express()3 const port = 30004 5 app.get('/', (req, res) => res.send('Hello World!'))6 7 app.listen(port, () => console.log("Example app listening on port " + port))COPY
Edit line 5 of this file, so the file looks like this:
/index.js1 const express = require('express')2 const app = express()3 const port = 30004 5 app.get('/', (req, res) => res.send('Hello DevSpace!'))6 7 app.listen(port, () => console.log("Example app listening on port " + port))COPY
After saving the file, the DevSpace CLI will immediatly synchronize the local code change to your DevSpace. This will trigger the hot reloading tool which reloads the web server. If you reload your browser afterwards, you can directly see the result of your change.
By default, the DevSpace CLI will synchronize all project files in both directions (up and down). To use more advanced sync rules, take a look at our sync config guide.
Deploying your Application (optional)
After building your your application, you can also deploy it with the DevSpace CLI. Simply run the following command:
1 devspace deployCOPY
The DevSpace CLI will print a URL at the end of the deployment process. After the containers are started (this may take up to 5 minutes), your application will be publicly available at this URL. To update your deployment, simply run devspace deploy again.
By default, you will have a so-called cloudProviderDeployTarget with the name "production" within your config file in .devspace/config.yaml. When you run devspace deploy, your helm chart will be deployed to this target. For more information about deploying applications with DevSpace CLI, check our DevSpace Deployment Guide.