Create a Workspace
Create a Workspace
You can create a workspace either from the Devsy CLI or through the Devsy desktop application. A workspace can be created from a Git repository, a local path or a Docker container (e.g. golang:latest).
Upon successful creation, Devsy will make the development container available through the ssh host WORKSPACE_NAME.devsy. Alternatively, Devsy can automatically open the workspace in a locally installed IDE, such as VS Code or Intellij.
A workspace is defined through a devcontainer.json. If Devsy can't find one, it will automatically try to guess the programming language of your project and provide a fitting template.
Via Devsy Desktop Application
Navigate to the 'Workspaces' view and click on the 'Create' button in the title to open the create-workspace wizard. The wizard walks through five steps:
- Provider: Select an initialized provider to host the workspace. Cannot be changed later. If no initialized provider exists, the wizard prompts you to add one (navigates to 'Providers' > 'Add').
- Source: Pick one of the Quick Start templates or enter a custom source (Git URL, image, or local path). Use 'Show advanced options' to optionally set a Workspace Folder (a subfolder within the source to use as the workspace root).
- IDE: Choose an IDE to open the workspace with. Optional; the default is
none. - Review: Optionally override the auto-derived Workspace Name and confirm the configuration.
- Launch: Devsy creates the workspace and streams progress. The workspace is launched in the chosen IDE on success.
Under the hood, the Desktop Application will call the CLI command devsy workspace up REPOSITORY
You can set the location of your devsy home by passing the --home={home_path} flag,
or by setting the env var DEVSY_HOME to your desired home directory.
This can be useful if you are having trouble with a workspace trying to mount to a windows location when it should be mounting to a path inside the WSL VM.
For example: setting --home=/mnt/c/Users/MyUser/ will result in a workspace path of something like /mnt/c/Users/MyUser/.devsy/contexts/default/workspaces/...
Via Devsy CLI
Make sure to install the Devsy CLI locally and select a provider you would like to host the workspace on (such as local docker) via:
# Add a provider if you haven't already
devsy provider add docker
Git Repository
Run the following command in a terminal to start a new workspace:
# Create from Git repository
devsy workspace up github.com/microsoft/vscode-remote-try-node
You can check out specific states of the repository by appending a commit hash, branch or Pull Request slug to the repository url:
Branch: devsy workspace up github.com/microsoft/vscode-remote-try-node@main
Commit: devsy workspace up github.com/microsoft/vscode-remote-try-node@sha256:15ba80171af11374143288fd3d54898860107323
PR: devsy workspace up github.com/microsoft/vscode-remote-try-node@pull/108/head # Only works for GitHub!
Devsy will forward git credentials to a remote machine so that you can also pull private repositories.
Use the --id flag to override the name of the workspace. This allows you to create multiple workspaces from the same repository.
Local Path
Run the following command in a terminal to create a new workspace:
# Create from a local path
devsy workspace up ./path/to/my-folder
Devsy will sync the folder into the remote machine and create a development environment from the devcontainer.json.
Docker Image
Run the following command in a terminal to create a new workspace from a docker image:
# Create from a docker image
devsy workspace up ghcr.io/my-org/my-repo:latest
Devsy will create the following .devcontainer.json:
{
"image": "ghcr.io/my-org/my-repo:latest"
}
Existing local container
If you have a local container running, you can create a workspace from it by running:
devsy workspace up my-workspace --source container:$CONTAINER_ID
This only works with the docker provider.
Using --recreate on a workspace based on an already existing container will be rejected.
Recreating a workspace
If you are working on the devcontainer.json or have pulled changes that affect the development environment, you can recreate a workspace. Recreating a workspace means to apply changes in the devcontainer.json or related Dockerfile to the development environment. If a prebuild repository is supplied, Devsy will try to find the updated development environment image inside the prebuild repository and if not found will fall back to building it.
When recreating a workspace, changes only to the project path or mounted volumes will be preserved. All other changes made in the container will be lost.
Via Devsy CLI
Run the following command to rebuild an existing workspace:
devsy workspace up my-workspace --recreate
Resetting a workspace
Some scenarios require pulling in the latest changes from a Git repository or re-uploading your local folder. If instead of recreating the devcontainer you need to completely restart your workspace from a clean slate, use Reset over Recreate.
** When recreating a workspace, no changes will be preserved! **
Via Devsy CLI
Run the following command to reset an existing workspace:
devsy workspace up my-workspace --reset