Skip to content

Commit

Permalink
Improved install.sh flags
Browse files Browse the repository at this point in the history
  • Loading branch information
nhooyr committed May 27, 2020
1 parent 42b5152 commit 7ef82d8
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 139 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ Run [VS Code](https://github.com/Microsoft/vscode) on any machine anywhere and a

## Highlights

- **Code everywhere:** Code on your Chromebook, tablet, and laptop with a
consistent dev environment. Develop on a Linux machine and pick up from any
device with a web browser.
- **Server-powered:** Take advantage of large cloud servers to speed up tests, compilations, downloads, and more.
Preserve battery life when you're on the go since all intensive tasks runs on your server.
Make use of a spare computer you have lying around and turn it into a full development environment.
- **Code everywhere**
- Code on your Chromebook, tablet, and laptop with a consistent development environment.
- Develop on a Linux machine and pick up from any device with a web browser.
- **Server-powered**
- Take advantage of large cloud servers to speed up tests, compilations, downloads, and more.
- Preserve battery life when you're on the go as all intensive tasks runs on your server.
- Make use of a spare computer you have lying around and turn it into a full development environment.

## Getting Started

For a full setup and walkthrough, please see [./doc/guide.md](./doc/guide.md).

[We have a script](./install.sh) to install code-server for Linux and macOS.
We have a [script](./install.sh) to install code-server for Linux and macOS.

It tries to use the system package manager if possible.

Expand All @@ -35,6 +36,10 @@ curl -fsSL https://code-server.dev/install.sh | sh

The install script will print out how to run and start using code-server.

If you believe an install script used with `curl | sh` is insecure, please give
[this wonderful blogpost](https://sandstorm.io/news/2015-09-24-is-curl-bash-insecure-pgp-verified-install) by
[sandstorm.io](https://sandstorm.io) a read.

Docs on the install script, manual installation and docker image are at [./doc/install.md](./doc/install.md).

## FAQ
Expand Down
4 changes: 2 additions & 2 deletions ci/build/build-code-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ MINIFY=${MINIFY-true}
main() {
cd "$(dirname "${0}")/../.."

npx tsc --outDir out --tsBuildInfoFile .cache/out.tsbuildinfo
tsc --outDir out --tsBuildInfoFile .cache/out.tsbuildinfo
# If out/node/entry.js does not already have the shebang,
# we make sure to add it and make it executable.
if ! grep -q -m1 "^#!/usr/bin/env node" out/node/entry.js; then
sed -i.bak "1s;^;#!/usr/bin/env node\n;" out/node/entry.js && rm out/node/entry.js.bak
chmod +x out/node/entry.js
fi

npx parcel build \
parcel build \
--public-url "/static/$(git rev-parse HEAD)/dist" \
--out-dir dist \
$([[ $MINIFY ]] || echo --no-minify) \
Expand Down
3 changes: 2 additions & 1 deletion ci/build/build-static-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ main() {
}

bundle_dynamic_lib() {
lib_name="$1"
local lib_name="$1"
local lib_path

if [[ $OS == "linux" ]]; then
lib_path="$(ldd "$RELEASE_PATH/lib/node" | grep "$lib_name" | awk '{print $3 }')"
Expand Down
2 changes: 1 addition & 1 deletion ci/build/code-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ bin_dir() {
BIN_DIR=$(bin_dir)
if [ "$(uname)" = "Linux" ]; then
export LD_LIBRARY_PATH="$BIN_DIR/../lib${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}"
else
elif [ "$(uname)" = "Darwin" ]; then
export DYLD_LIBRARY_PATH="$BIN_DIR/../lib${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}"
fi
exec "$BIN_DIR/../lib/node" "$BIN_DIR/.." "$@"
2 changes: 1 addition & 1 deletion doc/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ See https://cdn.vsassets.io/v/M146_20190123.39/_content/Microsoft-Visual-Studio-
> Marketplace Offerings are intended for use only with Visual Studio Products and Services
> and you may only install and use Marketplace Offerings with Visual Studio Products and Services.
As a result, [Coder](https://coder.com) has created its own marketplace for open source extensions.
As a result, we have created our own marketplace for open source extensions.
It works by scraping GitHub for VS Code extensions and building them. It's not perfect but getting
better by the day with more and more extensions.

Expand Down
74 changes: 36 additions & 38 deletions doc/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

This guide demonstrates how to setup and use code-server.
To reiterate, code-server lets you run VS Code on a remote server and then access it via a browser.
This guide demonstrates how to setup and use `code-server`.
To reiterate, `code-server` lets you run VS Code on a remote server and then access it via a browser.

Further docs are at:

- [README.md](../README.md) for a general overview
- [FAQ.md](./FAQ.md) for common questions.
- [CONTRIBUTING.md](../doc/CONTRIBUTING.md) for development docs
- [README](../README.md) for a general overview
- [INSTALL](../doc/install.md) for installation
- [FAQ](./FAQ.md) for common questions.
- [CONTRIBUTING](../doc/CONTRIBUTING.md) for development docs

We'll walk you through acquiring a remote machine to run code-server on
We'll walk you through acquiring a remote machine to run `code-server` on
and then exposing `code-server` so you can securely access it.

## 1. Acquire a remote machine

First, you need a machine to run code-server on. You can use a physical
First, you need a machine to run `code-server` on. You can use a physical
machine you have lying around or use a VM on GCP/AWS.

### Requirements
Expand Down Expand Up @@ -64,7 +65,6 @@ Once you've signed up and created a GCP project, create a new Compute Engine VM
- Click `Change` under `Boot Disk` and change the type to `SSD Persistent Disk` and the size
to `32`.
- You can always grow your disk later.
- The default OS of Debian 10 is fine.
8. Navigate to `Networking -> Network interfaces` and edit the existing interface
to use a static external IP.
- Click done to save network interface changes.
Expand All @@ -78,7 +78,7 @@ to avoid the slow dashboard.

## 2. Install code-server

[We have a script](./install.sh) to install code-server for Linux and macOS.
We have a [script](./install.sh) to install `code-server` for Linux and macOS.

It tries to use the system package manager if possible.

Expand All @@ -94,7 +94,7 @@ Now to actually install:
curl -fsSL https://code-server.dev/install.sh | sh
```

The install script will print out how to run and start using code-server.
The install script will print out how to run and start using `code-server`.

Docs on the install script, manual installation and docker image are at [./doc/install.md](./doc/install.md).

Expand All @@ -103,45 +103,44 @@ Docs on the install script, manual installation and docker image are at [./doc/i
**Never**, **ever** expose `code-server` directly to the internet without some form of authentication
and encryption as someone can completely takeover your machine with the terminal.

By default, code-server will enable password authentication which will
require you to copy the password from the code-server config file to login. Since it
cannot use TLS by default, it will listen on `localhost` to avoid exposing itself
to the world. This is fine for testing but will not work if you want to access `code-server`
By default, `code-server` will enable password authentication which will require you to copy the
password from the`code-server`config file to login. It will listen on`localhost` to avoid exposing
itself to the world. This is fine for testing but will not work if you want to access `code-server`
from a different machine.

There are several approaches to securely operating and exposing code-server.
There are several approaches to securely operating and exposing `code-server`.

**tip**: You can list the full set of code-server options with `code-server --help`
**tip**: You can list the full set of `code-server` options with `code-server --help`

### SSH forwarding

We highly recommend this approach for not requiring any additional setup, you just need an
SSH server on your remote machine. The downside is you won't be able to access `code-server`
without an SSH client like an iPad. If that's important to you, skip to [Let's Encrypt](#lets-encrypt).
on any machine without an SSH client like on iPad. If that's important to you, skip to [Let's Encrypt](#lets-encrypt).

Recommended reading: https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding.

First, ssh into your instance and edit your code-server config file to disable password authentication.
First, ssh into your instance and edit your `code-server` config file to disable password authentication.

```bash
# Replaces "auth: password" with "auth: none" in the code-server config.
sed -i.bak 's/auth: password/auth: none/' ~/.config/code-server/config.yaml
```

Restart code-server with (assuming you followed the guide):
Restart `code-server` with (assuming you followed the guide):

```bash
systemctl --user restart code-server
```

Now forward local port 8080 to `127.0.0.1:8080` on the remote instance.

Recommended reading: https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding.

```bash
# -N disables executing a remote shell
ssh -N -L 8080:127.0.0.1:8080 <instance-ip>
```

Now if you access http://127.0.0.1:8080 locally, you should see code-server!
Now if you access http://127.0.0.1:8080 locally, you should see `code-server`!

If you want to make the SSH port forwarding persistent we recommend using
[mutagen](https://mutagen.io/documentation/introduction/installation).
Expand All @@ -168,8 +167,8 @@ and sign commits without copying your keys.

### Let's Encrypt

[Let's Encrypt](https://letsencrypt.org) is a great option if you want to access code-server on an iPad
or do not want to use SSH forwarding. This does require that the remote machine is exposed to the internet.
[Let's Encrypt](https://letsencrypt.org) is a great option if you want to access `code-server` on an iPad
or do not want to use SSH forwarding. This does require that the remote machine be exposed to the internet.

Assuming you have been following the guide, edit your instance and checkmark the allow HTTP/HTTPS traffic options.

Expand Down Expand Up @@ -198,9 +197,9 @@ reverse_proxy 127.0.0.1:8080
sudo systemctl reload caddy
```

Visit `https://<your-domain-name>` to access code-server. Congratulations!
Visit `https://<your-domain-name>` to access `code-server`. Congratulations!

In a future release we plan to integrate Let's Encrypt directly with code-server to avoid
In a future release we plan to integrate Let's Encrypt directly with `code-server` to avoid
the dependency on caddy.

### Self Signed Certificate
Expand All @@ -210,13 +209,12 @@ have to use [Let's Encrypt](#lets-encrypt) instead. See the [FAQ](https://github

Recommended reading: https://security.stackexchange.com/a/8112.

We recommend this as a last resort as self signed certificates do not work with iPads and can
cause other bizarre issues. Not to mention all the warnings when you access code-server.
We recommend this as a last resort because self signed certificates do not work with iPads and can
cause other bizarre issues. Not to mention all the warnings when you access `code-server`.
Only use this if:

1. You do not want to buy a domain.
2. You cannot expose the remote machine to the internet.
3. You do not want to use SSH forwarding.
1. You do not want to buy a domain or you cannot expose the remote machine to the internet.
2. You do not want to use SSH forwarding.

ssh into your instance and edit your code-server config file to use a randomly generated self signed certificate:

Expand All @@ -229,32 +227,32 @@ sed -i.bak 's/bind-addr: 127.0.0.1:8080/bind-addr: 0.0.0.0:443/' ~/.config/code-
sudo setcap cap_net_bind_service=+ep /usr/lib/code-server/lib/node
```

Assuming you have been following the guide, restart code-server with:
Assuming you have been following the guide, restart `code-server` with:

```bash
systemctl --user restart code-server
```

Edit your instance and checkmark the allow HTTPS traffic option.

Visit `https://<your-instance-ip>` to access code-server.
Visit `https://<your-instance-ip>` to access `code-server`.
You'll get a warning when accessing but if you click through you should be good.

To avoid the warnings, you can use [mkcert](https://mkcert.dev) to create a self signed certificate
trusted by your OS and then pass it into code-server via the `cert` and `cert-key` config
trusted by your OS and then pass it into `code-server` via the `cert` and `cert-key` config
fields.

### Change the password?

Edit the `password` field in the code-server config file at `~/.config/code-server/config.yaml`
and then restart code-server with:
Edit the `password` field in the `code-server` config file at `~/.config/code-server/config.yaml`
and then restart `code-server` with:

```bash
systemctl --user restart code-server
```

### How do I securely access development web services?

If you're working on a web service and want to access it locally, code-server can proxy it for you.
If you're working on a web service and want to access it locally, `code-server` can proxy it for you.

See [FAQ.md](https://github.com/cdr/code-server/blob/master/doc/FAQ.md#how-do-i-securely-access-web-services).
See the [FAQ](https://github.com/cdr/code-server/blob/master/doc/FAQ.md#how-do-i-securely-access-web-services).
24 changes: 13 additions & 11 deletions doc/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- [install.sh](#installsh)
- [Flags](#flags)
- [Installation reference](#installation-reference)
- [Detect Reference](#detect-reference)
- [Debian, Ubuntu](#debian-ubuntu)
- [Fedora, CentOS, RHEL, SUSE](#fedora-centos-rhel-suse)
- [Arch Linux](#arch-linux)
Expand All @@ -20,7 +20,7 @@ various distros and operating systems.

## install.sh

[We have a script](./install.sh) to install code-server for Linux and macOS.
We have a [script](./install.sh) to install code-server for Linux and macOS.

It tries to use the system package manager if possible.

Expand All @@ -42,19 +42,21 @@ If you believe an install script used with `curl | sh` is insecure, please give
[this wonderful blogpost](https://sandstorm.io/news/2015-09-24-is-curl-bash-insecure-pgp-verified-install) by
[sandstorm.io](https://sandstorm.io) a read.

If you'd still prefer manual installation despite the below [reference](#reference) and `--dry-run`
If you'd still prefer manual installation despite the below [detect reference](#detect-reference) and `--dry-run`
then continue on for docs on manual installation. The [`install.sh`](./install.sh) script runs the _exact_ same
commands presented in the rest of this document.

### Flags

- `--dry-run` to echo the commands for the install process without running them.
- `--static` to install a static release into `~/.local`.
- `--static=/usr/local` to install a static release system wide.
- `--method` to choose the installation method.
- `--method=detect` to detect the package manager but fallback to `--method=archive`.
- `--method=archive` to install a static release archive into `~/.local`.
- `--prefix=/usr/local` to install a static release archive system wide.
- `--version=X.X.X` to install version `X.X.X` instead of latest.
- `--help` to see full usage docs.

### Reference
### Detect Reference

- For Debian, Ubuntu and Raspbian it will install the latest deb package.
- For Fedora, CentOS, RHEL and openSUSE it will install the latest rpm package.
Expand All @@ -66,7 +68,7 @@ commands presented in the rest of this document.
- For macOS it will install the Homebrew package.

- If Homebrew is not installed it will install the latest static release into `~/.local`.
- Add ~/.local/bin to your \$PATH to run code-server.
- Add `~/.local/bin` to your `$PATH` to run code-server.

- If ran on an architecture with no binary releases, it will install the npm package with `yarn` or `npm`.
- We only have binary releases for amd64 and arm64 presently.
Expand Down Expand Up @@ -137,14 +139,14 @@ brew services start code-server
## Static Releases

We publish self contained `.tar.gz` archives for every release on [github](https://github.com/cdr/code-server/releases).
They bundle the node binary and node_modules.
They bundle the node binary and `node_modules`.

1. Download the latest release archive for your system from [github](https://github.com/cdr/code-server/releases).
2. Unpack the release.
3. You can run code-server by executing `./bin/code-server`.

You can add the code-server `bin` directory to your `$PATH` or link to it from a
directory in your `$PATH` to easily execute `code-server` without the full path every time.
You can add the code-server `bin` directory to your `$PATH` to easily execute `code-server`
without the full path every time.

Here is an example script for installing and using a static `code-server` release on Linux:

Expand Down Expand Up @@ -174,6 +176,6 @@ docker run -it -p 127.0.0.1:8080:8080 \

Our official image supports `amd64` and `arm64`.

For `arm32` support there is a highly popular community maintained alternative:
For `arm32` support there is a popular community maintained alternative:

https://hub.docker.com/r/linuxserver/code-server
Loading

0 comments on commit 7ef82d8

Please sign in to comment.