Skip to content

Integrate Coder Cloud Agent #2086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
579bb94
Add coder cloud expose command
nhooyr Sep 8, 2020
c7c62da
Remove unused code in optionDescriptions
nhooyr Sep 8, 2020
916e24e
Add support for multiline descriptions
nhooyr Sep 9, 2020
55a7e8b
Implement automatic cloud proxying
nhooyr Sep 9, 2020
0aa9827
Fixes for CI
nhooyr Sep 9, 2020
eacca7d
Unrelated fixes for CI
nhooyr Sep 9, 2020
b22f3cb
Add $HOME to ./ci/dev/image/run.sh
nhooyr Sep 15, 2020
607444c
Switch off debian:8 to debian:10 for the typescript build image
nhooyr Sep 15, 2020
22c4a7e
Make linking and starting code-server to the cloud a single command
nhooyr Sep 28, 2020
9035bfa
Add coder cloud agent binary to build process
nhooyr Oct 6, 2020
c308ae0
Ignore dirty lib/vscode
nhooyr Oct 6, 2020
fae07e1
Fix Go inside dev image
nhooyr Oct 6, 2020
dd996d8
v3.6.0
nhooyr Oct 6, 2020
6e8248c
Fix zip release creation
nhooyr Oct 6, 2020
c3c24fe
Fixes for @ammarb
nhooyr Oct 7, 2020
1c16814
Update coder-bind docs
nhooyr Oct 7, 2020
4b3c089
Remove dead code
nhooyr Oct 7, 2020
c4f1c05
Show valid values for --auth in --help
nhooyr Oct 7, 2020
bfe731f
Ensure socket is undefined with --coder-bind
nhooyr Oct 7, 2020
7cc16ce
Document KEEP_MODULES
nhooyr Oct 7, 2020
df3089f
coder-cloud: Use consolidated bind command
nhooyr Oct 7, 2020
ebbcb8d
Update yarn.lock
nhooyr Oct 7, 2020
85b0804
Remove cliArgs from main
nhooyr Oct 7, 2020
3e28ab8
Add debug log for options passed to the agent
nhooyr Oct 7, 2020
febf4ea
Fix the clean script
nhooyr Oct 7, 2020
f5489cd
Hide -coder-bind for now
nhooyr Oct 9, 2020
9ff3797
Make --coder-bind disable HTTPS
nhooyr Oct 9, 2020
a5b6d08
Add CS_BETA and note --coder-bind is in beta
nhooyr Oct 9, 2020
9002f11
Remove the extra releases for autoupdating purposes
nhooyr Oct 9, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Run ./ci/steps/fmt.sh
uses: ./ci/images/debian8
uses: ./ci/images/debian10
with:
args: ./ci/steps/fmt.sh

Expand All @@ -17,7 +17,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Run ./ci/steps/lint.sh
uses: ./ci/images/debian8
uses: ./ci/images/debian10
with:
args: ./ci/steps/lint.sh

Expand All @@ -26,7 +26,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Run ./ci/steps/test.sh
uses: ./ci/images/debian8
uses: ./ci/images/debian10
with:
args: ./ci/steps/test.sh

Expand All @@ -35,7 +35,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Run ./ci/steps/release.sh
uses: ./ci/images/debian8
uses: ./ci/images/debian10
with:
args: ./ci/steps/release.sh
- name: Upload npm package artifact
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
name: release-packages
path: ./release-packages
- name: Run ./ci/steps/build-docker-image.sh
uses: ./ci/images/debian8
uses: ./ci/images/debian10
with:
args: ./ci/steps/build-docker-image.sh
- name: Upload release image
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Run ./ci/steps/publish-npm.sh
uses: ./ci/images/debian8
uses: ./ci/images/debian10
with:
args: ./ci/steps/publish-npm.sh
env:
Expand All @@ -22,7 +22,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Run ./ci/steps/push-docker-manifest.sh
uses: ./ci/images/debian8
uses: ./ci/images/debian10
with:
args: ./ci/steps/push-docker-manifest.sh
env:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ release-images/
node_modules
node-*
/plugins
/lib/coder-cloud-agent
.home
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "lib/vscode"]
path = lib/vscode
url = https://github.com/microsoft/vscode
ignore = dirty
6 changes: 6 additions & 0 deletions ci/build/build-code-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ main() {
chmod +x out/node/entry.js
fi

if ! [ -f ./lib/coder-cloud-agent ]; then
OS="$(uname | tr '[:upper:]' '[:lower:]')"
curl -fsSL "https://storage.googleapis.com/coder-cloud-releases/agent/latest/$OS/cloud-agent" -o ./lib/coder-cloud-agent
chmod +x ./lib/coder-cloud-agent
fi

parcel build \
--public-url "." \
--out-dir dist \
Expand Down
2 changes: 1 addition & 1 deletion ci/build/build-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ release_archive() {
elif [[ $OS == "darwin" && $ARCH == "x86_64" ]]; then
# Just exists to make autoupdating from 3.2.0 work again.
mv ./release-standalone "./$release_name"
zip -r "release-packages/$release_name.zip" "./$release_name"
zip -yr "release-packages/$release_name.zip" "./$release_name"
mv "./$release_name" ./release-standalone
return
else
Expand Down
2 changes: 1 addition & 1 deletion ci/build/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ main() {
rsync README.md "$RELEASE_PATH"
rsync LICENSE.txt "$RELEASE_PATH"
rsync ./lib/vscode/ThirdPartyNotices.txt "$RELEASE_PATH"
rsync ./lib/coder-cloud-agent "$RELEASE_PATH/lib"

# code-server exports types which can be imported and used by plugins. Those
# types import ipc.d.ts but it isn't included in the final vscode build so
Expand Down Expand Up @@ -57,7 +58,6 @@ EOF
rsync yarn.lock "$RELEASE_PATH"
rsync ci/build/npm-postinstall.sh "$RELEASE_PATH/postinstall.sh"


if [ "$KEEP_MODULES" = 1 ]; then
rsync node_modules/ "$RELEASE_PATH/node_modules"
fi
Expand Down
11 changes: 1 addition & 10 deletions ci/build/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@ main() {
cd "$(dirname "${0}")/../.."
source ./ci/lib.sh

rm -rf \
out \
release \
release-standalone \
release-packages \
release-gcp \
release-images \
dist \
.cache \
node-*
git clean -Xffd

pushd lib/vscode
git clean -xffd
Expand Down
8 changes: 7 additions & 1 deletion ci/dev/image/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ set -euo pipefail
main() {
cd "$(dirname "$0")/../../.."
source ./ci/lib.sh
mkdir -p .home

docker run \
-it \
--rm \
-v "$PWD:/src" \
-e HOME="/src/.home" \
-e USER="coder" \
-e GITHUB_TOKEN \
-e KEEP_MODULES \
-e MINIFY \
-w /src \
-p 127.0.0.1:8080:8080 \
-u "$(id -u):$(id -g)" \
-e CI \
"$(docker_build ./ci/images/debian8)" \
"$(docker_build ./ci/images/"${IMAGE-debian10}")" \
"$@"
}

Expand Down
5 changes: 1 addition & 4 deletions ci/dev/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ main() {
eslint --max-warnings=0 --fix $(git ls-files "*.ts" "*.tsx" "*.js")
stylelint $(git ls-files "*.css")
tsc --noEmit
# See comment in ./ci/image/debian8
if [[ ! ${CI-} ]]; then
shellcheck -e SC2046,SC2164,SC2154,SC1091,SC1090,SC2002 $(git ls-files "*.sh")
fi
shellcheck -e SC2046,SC2164,SC2154,SC1091,SC1090,SC2002 $(git ls-files "*.sh")
}

main "$@"
11 changes: 8 additions & 3 deletions ci/images/centos7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@ RUN npm config set python python2
RUN yum install -y epel-release && yum install -y jq
RUN yum install -y rsync

# Copied from ../debian8/Dockerfile
# Install Go dependencies
# Copied from ../debian10/Dockerfile
# Install Go.
RUN ARCH="$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/')" && \
curl -fsSL "https://dl.google.com/go/go1.14.3.linux-$ARCH.tar.gz" | tar -C /usr/local -xz
ENV PATH=/usr/local/go/bin:/root/go/bin:$PATH
ENV GOPATH=/gopath
# Ensures running this image as another user works.
RUN mkdir -p $GOPATH && chmod -R 777 $GOPATH
ENV PATH=/usr/local/go/bin:$GOPATH/bin:$PATH

# Install Go dependencies
ENV GO111MODULE=on
RUN go get mvdan.cc/sh/v3/cmd/shfmt
RUN go get github.com/goreleaser/nfpm/cmd/nfpm
Expand Down
31 changes: 13 additions & 18 deletions ci/images/debian8/Dockerfile → ci/images/debian10/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:8
FROM debian:10

RUN apt-get update

Expand All @@ -24,28 +24,23 @@ RUN apt-get install -y build-essential \
RUN apt-get install -y gettext-base

# Misc build dependencies.
RUN apt-get install -y git rsync unzip

# We need latest jq from debian buster for date support.
RUN ARCH="$(dpkg --print-architecture)" && \
curl -fsSOL http://http.us.debian.org/debian/pool/main/libo/libonig/libonig5_6.9.1-1_$ARCH.deb && \
dpkg -i libonig*.deb && \
curl -fsSOL http://http.us.debian.org/debian/pool/main/j/jq/libjq1_1.5+dfsg-2+b1_$ARCH.deb && \
dpkg -i libjq*.deb && \
curl -fsSOL http://http.us.debian.org/debian/pool/main/j/jq/jq_1.5+dfsg-2+b1_$ARCH.deb && \
dpkg -i jq*.deb && rm *.deb
RUN apt-get install -y git rsync unzip jq

# Installs shellcheck.
# Unfortunately coredumps on debian:8 so disabled for now.
#RUN curl -fsSL https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.linux.$(uname -m).tar.xz | \
# tar -xJ && \
# mv shellcheck*/shellcheck /usr/local/bin && \
# rm -R shellcheck*
RUN curl -fsSL https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.linux.$(uname -m).tar.xz | \
tar -xJ && \
mv shellcheck*/shellcheck /usr/local/bin && \
rm -R shellcheck*

# Install Go dependencies
# Install Go.
RUN ARCH="$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/')" && \
curl -fsSL "https://dl.google.com/go/go1.14.3.linux-$ARCH.tar.gz" | tar -C /usr/local -xz
ENV PATH=/usr/local/go/bin:/root/go/bin:$PATH
ENV GOPATH=/gopath
# Ensures running this image as another user works.
RUN mkdir -p $GOPATH && chmod -R 777 $GOPATH
ENV PATH=/usr/local/go/bin:$GOPATH/bin:$PATH

# Install Go dependencies
ENV GO111MODULE=on
RUN go get mvdan.cc/sh/v3/cmd/shfmt
RUN go get github.com/goreleaser/nfpm/cmd/nfpm
Expand Down
5 changes: 3 additions & 2 deletions ci/release-image/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
set -eu

# This isn't set by default.
export USER="$(whoami)"
USER="$(whoami)"
export USER

if [ "${DOCKER_USER-}" != "$USER" ]; then
echo "$DOCKER_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd > /dev/null
Expand All @@ -11,7 +12,7 @@ if [ "${DOCKER_USER-}" != "$USER" ]; then
sudo usermod --login "$DOCKER_USER" coder
sudo groupmod -n "$DOCKER_USER" coder

export USER="$(whoami)"
USER="$DOCKER_USER"

sudo sed -i "/coder/d" /etc/sudoers.d/nopasswd
sudo sed -i "s/coder/$DOCKER_USER/g" /etc/fixuid/config.yml
Expand Down
11 changes: 9 additions & 2 deletions doc/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Differences:
- We require a minimum of node v12 but later versions should work.
- We use [nfpm](https://github.com/goreleaser/nfpm) to build `.deb` and `.rpm` packages.
- We use [jq](https://stedolan.github.io/jq/) to build code-server releases.
- The [CI container](../ci/images/debian8/Dockerfile) is a useful reference for all our dependencies.
- The [CI container](../ci/images/debian10/Dockerfile) is a useful reference for all our dependencies.

## Development Workflow

Expand Down Expand Up @@ -76,7 +76,7 @@ node .
Build release packages (make sure you run `./ci/steps/release.sh` first):

```
./ci/dev/image/run.sh ./ci/steps/release-packages.sh
IMAGE=centos7 ./ci/dev/image/run.sh ./ci/steps/release-packages.sh
# The standalone release is in ./release-standalone
# .deb, .rpm and the standalone archive are in ./release-packages
```
Expand All @@ -99,6 +99,13 @@ yarn test:standalone-release
yarn package
```

For a faster release build you can also run:

```
KEEP_MODULES=1 ./ci/steps/release.sh
node ./release
```

## Structure

The `code-server` script serves an HTTP API to login and start a remote VS Code process.
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "code-server",
"license": "MIT",
"version": "3.5.0",
"version": "3.6.0",
"description": "Run VS Code on a remote server.",
"homepage": "https://github.com/cdr/code-server",
"bugs": {
Expand Down Expand Up @@ -39,6 +39,7 @@
"@types/pem": "^1.9.5",
"@types/safe-compare": "^1.1.0",
"@types/semver": "^7.1.0",
"@types/split2": "^2.1.6",
"@types/tar-fs": "^2.0.0",
"@types/tar-stream": "^2.1.0",
"@types/ws": "^7.2.6",
Expand Down Expand Up @@ -76,6 +77,7 @@
"safe-buffer": "^5.1.1",
"safe-compare": "^1.1.4",
"semver": "^7.1.3",
"split2": "^3.2.2",
"tar": "^6.0.1",
"tar-fs": "^2.0.0",
"ws": "^7.2.0",
Expand Down
38 changes: 31 additions & 7 deletions src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export interface Args extends VsArgs {
readonly _: string[]
readonly "reuse-window"?: boolean
readonly "new-window"?: boolean

readonly "coder-bind"?: OptionalString
}

interface Option<T> {
Expand Down Expand Up @@ -130,7 +132,8 @@ const options: Options<Required<Args>> = {
"install-extension": {
type: "string[]",
description:
"Install or update a VS Code extension by id or vsix. The identifier of an extension is `${publisher}.${name}`. To install a specific version provide `@${version}`. For example: '[email protected]'.",
"Install or update a VS Code extension by id or vsix. The identifier of an extension is `${publisher}.${name}`.\n" +
"To install a specific version provide `@${version}`. For example: '[email protected]'.",
},
"enable-proposed-api": {
type: "string[]",
Expand All @@ -155,6 +158,15 @@ const options: Options<Required<Args>> = {
locale: { type: "string" },
log: { type: LogLevel },
verbose: { type: "boolean", short: "vvv", description: "Enable verbose logging." },

"coder-bind": {
type: OptionalString,
description: `
Securely bind code-server via Coder Cloud with the passed name. You'll get a URL like
https://myname.coder-cloud.com at which you can easily access your code-server instance.
Authorization is done via GitHub.
`,
},
}

export const optionDescriptions = (): string[] => {
Expand All @@ -166,12 +178,24 @@ export const optionDescriptions = (): string[] => {
}),
{ short: 0, long: 0 },
)
return entries.map(
([k, v]) =>
`${" ".repeat(widths.short - (v.short ? v.short.length : 0))}${v.short ? `-${v.short}` : " "} --${k}${" ".repeat(
widths.long - k.length,
)} ${v.description}${typeof v.type === "object" ? ` [${Object.values(v.type).join(", ")}]` : ""}`,
)
return entries.map(([k, v]) => {
const help = `${" ".repeat(widths.short - (v.short ? v.short.length : 0))}${v.short ? `-${v.short}` : " "} --${k} `
return (
help +
v.description
?.trim()
.split(/\n/)
.map((line, i) => {
line = line.trim()
if (i === 0) {
return " ".repeat(widths.long - k.length) + line
}
return " ".repeat(widths.long + widths.short + 6) + line
})
.join("\n") +
(typeof v.type === "object" ? ` [${Object.values(v.type).join(", ")}]` : "")
)
})
}

export const parse = (
Expand Down
Loading