一个 CLI,可在几秒钟内在云提供商帐户中创建远程开发环境
Recode
Remote development environments defined as code. Running in your cloud provider account. Currently available on Amazon Web Services and Visual Studio Code.
... you can think of it as a desktop version of Gitpod / Coder / GitHub Codespaces less polished and with less features but 100% free, 100% open-source and 100% community-driven
recode aws start recode-sh/workspace --instance-type t2.mediumhttps://user-images.githubusercontent.com/1233275/172346442-d6fef09c-2ef0-4633-8d72-e20bef8fc1a9.mp4
... see the recode-sh/workspace repository for an example of development environment configuration
The Recode binary has been tested on Linux and Mac. Support for Windows is theoretical (testers needed ).
Before using Recode, the following dependencies need to be installed:
Visual Studio Code (currently the sole editor supported).
OpenSSH Client (used to access your development environments).
The easiest way to install Recode is by running the following command in your terminal:
curl -sf https://raw.githubusercontent.com/recode-sh/cli/main/install.sh | sh -s -- -b /usr/local/bin latestThis command could be run as-is or by changing:
The installation directory by replacing /usr/local/bin with your preferred path.
The version installed by replacing latest with a specific version.
Once done, you could confirm that Recode is installed by running the recode command:
recode --help…recode loginTo begin, you need to run the login command to connect your GitHub account.
Recode requires the following permissions:
"Public SSH keys" and "Repositories" to let you access your repositories from your development environments.
"GPG Keys" and "Personal user data" to configure Git and sign your commits (verified badge).
All your data (including the OAuth access token) are only stored locally in ~/.config/recode/recode.yml (or in XDG_CONFIG_HOME if set).
The source code that implements the GitHub OAuth flow is located in the recode-sh/api repository.
recode start The start command creates and starts a development environment for a specific GitHub repository.
If a development environment is stopped, it will only be started. If a development environment is already started, only your code editor will be opened.
An --instance-type flag could be passed to specify the instance type that will power your development environment. (See the corresponding cloud provider repository for default / valid values).
recode aws start recode-sh/workspacerecode aws start recode-sh/workspace --instance-type t2.mediumrecode stop The stop command stops a started development environment.
Stopping means that the underlying instance will be stopped but your data will be conserved. You may want to use this command to save costs when the development environment is not used.
recode aws stop recode-sh/workspacerecode remove The remove command removes an existing development environment.
Removing means that the underlying instance and all your data will be permanently removed.
recode aws remove recode-sh/workspacerecode uninstallThe uninstall command removes all the infrastructure components used by Recode from your cloud provider account. (See the corresponding cloud provider repository for details).
Before running this command, all development environments need to be removed.
recode aws uninstallIf you think about all the projects you've worked on, you may notice that you've:
a set of configuration / tools used for all your projects (eg: a preferred timezone / locale, a specific shell...);
a set of configuration / tools specific for each project (eg: docker compose, go >= 1.18 or node.js >= 14).
This is what Recode has tried to mimic with user and project configuration.
--rebuild flagrecode aws start recode-sh/workspace --rebuildIf you update the configuration of an existing development environment, you could use the --rebuild flag of the start command to rebuild it without having to delete it first.
Docker and Docker compose are already preinstalled in all development environments so you don't have to install them.
User configuration corresponds to the set of configuration / tools used for all your projects. To create an user configuration, all you need to do is to:
Create a repository named .recode in your personal GitHub account.
Add a file named dev_env.Dockerfile in it.
The file dev_env.Dockerfile is a regular Dockerfile except that:
it must derive from recode-sh/base-dev-env (more below);
the user configuration needs to be applied to the user recode.
Otherwise, you are free to do what you want with this file and this repository. You could see an example with dotfiles in recode-sh/.recode and use it as a GitHub repository template:
…Project configuration corresponds to the set of configuration / tools specific for each project. As you may have guessed, to create a project configuration, all you need to do is to:
Create a directory named .recode in your project's repository.
Add a file named dev_env.Dockerfile in it.
The file dev_env.Dockerfile is a regular Dockerfile except that:
it must derive from user_dev_env (your user configuration);
the user configuration needs to be applied to the user recode.
Otherwise, you are free to do what you want with this file and this directory. You could see an example in recode-sh/workspace:
…If you don't have an user configuration, the recode-sh/.recode repository will be used as a default one.
That's why you will have zsh configured as default shell in your project.
As you may have noticed from previous sections, some commands in the dev_env.Dockerfile files (like the LABEL ones) are specific to Recode. This section will try to explain them.
As you may have understood, all the development environments derive directly or indirectly from recode-sh/base-dev-env. You could see the source of this Docker image in the recode-sh/base-dev-env repository:
…As you can see, nothing fancy here.
Recode is built on ubuntu with docker and docker compose pre-installed. An user recode is created and configured to be used as the default user. Root privileges are managed via sudo.
Your repositories will be cloned in /home/recode/workspace. A default timezone and locale are set.
(To learn more, see the recode-sh/base-dev-env repository).
In order to require Visual Studio Code extensions to be installed in your development environment, you need to add a LABEL named sh.recode.vscode.extensions in your user's or project's dev_env.Dockerfile.
(As you may have guessed, if this label is added to your user configuration, all your projects will have the listed extensions installed).
An extension is identified using its publisher name and extension identifier (publisher.extension). You can see the name on the extension's detail page.
LABEL sh.recode.vscode.extensions="golang.go, zxh404.vscode-proto3, ms-azuretools.vscode-docker"If you want to use multiple repositories in your development environment, you need to add a LABEL named sh.recode.repositories in your project's dev_env.Dockerfile.
In this case, we recommend you to create an empty repository that will only contain the .recode directory (as an example, see the recode-sh/workspace repository).
(As you may have guessed, if this label is added to your user configuration it will be ignored).
Repositories may be set as relative to the current one (eg: cli) or fully qualified (eg: recode-sh/cli).
LABEL sh.recode.repositories="cli, agent, recode, aws-cloud-provider, base-dev-env, api, .recode, workspace"RECODE_INSTANCE_OS and RECODE_INSTANCE_ARCH)Given the nature of this project, you need to take into account the fact that the characteristics of the instance used to run your development environment may vary depending on the one chosen by the final user.
As an example, an user may want to use an AWS graviton powered instance to run your project and, as a result, your project's dev_env.Dockerfile must be ready to be built for ARM.
To ease this process, Recode will pass to your dev_env.Dockerfile files two build arguments RECODE_INSTANCE_OS and RECODE_INSTANCE_ARCH that will contain both the current operating system (linux) and architecture (eg: amd64) respectively.
# Reserved args (RECODE_*). Provided by Recode.
# eg: linux
ARG RECODE_INSTANCE_OS
# eg: amd64 or arm64
ARG RECODE_INSTANCE_ARCHHooks are shell scripts that will be run during the lifetime of your development environment. To be able to add a hook in a project, all you have to do is to add a directory named hooks in your .recode directory.
Before adding your first h
暂无开放 Issues,或尚未同步最近议题。