Shake CI and docs up

This commit is contained in:
Anmol Sethi 2020-02-14 18:54:52 -05:00
parent b8fa7da972
commit 80b1b1b672
No known key found for this signature in database
GPG Key ID: 8CEF1878FF10ADEB
49 changed files with 392 additions and 1424 deletions

View File

@ -1,12 +0,0 @@
Dockerfile
build
deployment
doc
.github
.gitignore
.node-version
.travis.yml
LICENSE
README.md
node_modules
release

View File

@ -1,331 +0,0 @@
kind: pipeline
type: docker
name: amd64:linux
platform:
arch: amd64
steps:
- name: cache:restore
image: codercom/nbin:centos
commands:
- yum install -y libxkbfile-devel libsecret-devel
- . /opt/rh/devtoolset-6/enable
- ./scripts/cacher.sh
- name: lint
image: node:12
commands:
- yarn lint
- name: test
image: codercom/nbin:centos
commands:
- yum install -y openssl
- yarn test
- name: build
image: codercom/nbin:centos
commands:
- yum install -y libxkbfile-devel libsecret-devel
- . /opt/rh/devtoolset-6/enable
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing to preserve cache for the next run'
- name: cache:package
image: node:12
commands:
- ./scripts/cacher.sh
when:
event: push
- name: cache:push
image: plugins/gcs
settings:
source: cache-upload/
target: codesrv-ci.cdr.sh
token:
from_secret: gcs-token
when:
event: push
- name: test:build
image: codercom/nbin:centos
commands:
- yarn test:build
- name: publish:github
image: plugins/github-release
settings:
api_key:
from_secret: github_token
files: release/*.tar.gz
draft: true
overwrite: true
title: ${DRONE_TAG}
when:
event: tag
- name: publish:docker
image: plugins/docker
settings:
username:
from_secret: docker_user
password:
from_secret: docker_pass
repo: codercom/code-server
dockerfile: scripts/ci.dockerfile
tags:
- ${DRONE_TAG}
when:
event: tag
- name: publish:gcs
image: plugins/gcs
settings:
source: binary-upload
target: codesrv-ci.cdr.sh/
token:
from_secret: gcs-token
when:
event: tag
---
kind: pipeline
type: docker
name: amd64:alpine
platform:
arch: amd64
steps:
- name: cache:restore
image: node:12-alpine
commands:
- apk add libxkbfile-dev libsecret-dev build-base git bash python
- ./scripts/cacher.sh
- name: lint
image: node:12-alpine
commands:
- yarn lint
- name: test
image: node:12-alpine
commands:
- apk add openssl
- yarn test
- name: build
image: node:12-alpine
commands:
- apk add libxkbfile-dev libsecret-dev build-base git bash python
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing to preserve cache for the next run'
- name: cache:package
image: node:12-alpine
commands:
- ./scripts/cacher.sh
when:
event: push
- name: cache:push
image: plugins/gcs
settings:
source: cache-upload/
target: codesrv-ci.cdr.sh
token:
from_secret: gcs-token
when:
event: push
- name: test:build
image: node:12-alpine
commands:
- yarn test:build
- name: publish:github
image: plugins/github-release
settings:
api_key:
from_secret: github_token
files: release/*.tar.gz
draft: true
overwrite: true
title: ${DRONE_TAG}
when:
event: tag
- name: publish:gcs
image: plugins/gcs
settings:
source: binary-upload
target: codesrv-ci.cdr.sh/
token:
from_secret: gcs-token
when:
event: tag
---
kind: pipeline
type: docker
name: arm64:linux
platform:
arch: arm64
steps:
- name: cache:restore
image: node:12
commands:
- apt update && apt install -y build-essential git libsecret-1-dev libx11-dev libxkbfile-dev
- ./scripts/cacher.sh
- name: lint
image: node:12
commands:
- yarn lint
- name: test
image: node:12
commands:
- yarn test
- name: build
image: node:12
commands:
- apt update && apt install -y build-essential git libsecret-1-dev libx11-dev libxkbfile-dev
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing to preserve cache for the next run'
- name: cache:package
image: node:12
commands:
- ./scripts/cacher.sh
when:
event: push
- name: cache:push
image: plugins/gcs
settings:
source: cache-upload/
target: codesrv-ci.cdr.sh
token:
from_secret: gcs-token
when:
event: push
- name: test:build
image: node:12
commands:
- yarn test:build
- name: publish:github
image: plugins/github-release
settings:
api_key:
from_secret: github_token
files: release/*.tar.gz
draft: true
overwrite: true
title: ${DRONE_TAG}
when:
event: tag
- name: publish:docker
image: plugins/docker
settings:
username:
from_secret: docker_user
password:
from_secret: docker_pass
repo: codercom/code-server
dockerfile: scripts/ci.dockerfile
tags:
- ${DRONE_TAG}-arm64
when:
event: tag
- name: publish:gcs
image: plugins/gcs
settings:
source: binary-upload
target: codesrv-ci.cdr.sh/
token:
from_secret: gcs-token
when:
event: tag
---
kind: pipeline
type: docker
name: arm64:alpine
platform:
arch: arm64
steps:
- name: cache:restore
image: node:12-alpine
commands:
- apk add libxkbfile-dev libsecret-dev build-base git bash python
- ./scripts/cacher.sh
- name: lint
image: node:12-alpine
commands:
- yarn lint
- name: test
image: node:12-alpine
commands:
- apk add openssl
- yarn test
- name: build
image: node:12-alpine
commands:
- apk add libxkbfile-dev libsecret-dev build-base git bash python
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing to preserve cache for the next run'
- name: cache:package
image: node:12-alpine
commands:
- ./scripts/cacher.sh
when:
event: push
- name: cache:push
image: plugins/gcs
settings:
source: cache-upload/
target: codesrv-ci.cdr.sh
token:
from_secret: gcs-token
when:
event: push
- name: test:build
image: node:12-alpine
commands:
- yarn test:build
- name: publish:github
image: plugins/github-release
settings:
api_key:
from_secret: github_token
files: release/*.tar.gz
draft: true
overwrite: true
title: ${DRONE_TAG}
when:
event: tag
- name: publish:gcs
image: plugins/gcs
settings:
source: binary-upload
target: codesrv-ci.cdr.sh/
token:
from_secret: gcs-token
when:
event: tag

View File

@ -1,6 +0,0 @@
root = true
[*]
indent_style = space
trim_trailing_whitespace = true
indent_size = 2

3
.github/CODEOWNERS vendored
View File

@ -1,2 +1 @@
* @code-asher @kylecarbs
Dockerfile @nhooyr
* @code-asher @nhooyr

View File

@ -1,22 +0,0 @@
---
name: Bug Report
about: Report problems and unexpected behavior.
title: ''
labels: 'bug'
assignees: ''
---
<!-- Please search existing issues to avoid creating duplicates. -->
<!-- All extension-specific issues should be created with the `Extension Bug` template. -->
- `code-server` version: <!-- The version of code-server -->
- OS Version: <!-- OS version, cloud provider, -->
## Description
<!-- Describes the problem here -->
## Steps to Reproduce
1. <!-- step 1: click ... -->
1. <!-- step 2: ... -->

View File

@ -1,22 +0,0 @@
---
name: Extension Bug
about: Report problems and unexpected behavior with extensions.
title: ''
labels: 'extension-specific'
assignees: ''
---
<!-- Please search existing issues to avoid creating duplicates. -->
- `code-server` version: <!-- The version of code-server -->
- OS Version: <!-- OS version, cloud provider, -->
- Extension: <!-- Link to extension -->
## Description
<!-- Describes the problem here -->
## Steps to Reproduce
1. <!-- step 1: click ... -->
1. <!-- step 2: ... -->

View File

@ -1,11 +0,0 @@
---
name: Feature Request
about: Suggest an idea for this project.
title: ''
labels: 'feature'
assignees: ''
---
<!-- Please search existing issues to avoid creating duplicates. -->
<!-- Describe the feature you'd like. -->

4
.github/issue_template.md vendored Normal file
View File

@ -0,0 +1,4 @@
<!--
Please file all questions and support requests at https://www.reddit.com/r/codeserver/
The issue tracker is only for bugs.
-->

View File

@ -1,6 +1,4 @@
<!-- Please answer these questions before submitting your PR. Thanks! -->
### Describe in detail the problem you had and how this PR fixes it
### Is there an open issue you can link to?
<!--
Please link to the issue this PR solves.
If there is no existing issue, please first create one unless the fix is minor.
-->

24
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,24 @@
name: ci
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: yarn lint
uses: ./ci/image
with:
args: yarn && yarn lint

6
.gitignore vendored
View File

@ -1,11 +1,7 @@
*.tsbuildinfo
.cache
binaries
*-upload
build
dist*
node_modules
out*
release
source
yarn-cache
node_modules

View File

@ -1 +0,0 @@
12.14.0

1
.npmrc
View File

@ -1 +0,0 @@
scripts-prepend-node-path=true

View File

@ -1,7 +1,4 @@
printWidth: 120
semi: false
tabWidth: 2
singleQuote: false
trailingComma: es5
useTabs: false
trailingComma: all
arrowParens: always

View File

@ -1,37 +0,0 @@
language: node_js
node_js:
- 12.14.0
services:
- docker
jobs:
include:
- name: "MacOS build"
os: osx
script: travis_wait 60 scripts/ci.bash
git:
depth: 3
deploy:
- provider: releases
file_glob: true
draft: true
tag_name: "$TRAVIS_TAG"
target_commitish: "$TRAVIS_COMMIT"
name: "$TRAVIS_TAG"
skip_cleanup: true
api_key:
secure: YL/x24KjYjgYXPcJWk3FV7FGxI79Mh6gBECQEcdlf3fkLEoKFVgzHBoUNWrFPzyR4tgLyWNAgcpD9Lkme1TRWTom7UPjXcwMNyLcLa+uec7ciSAnYD9ntLTpiCuPDD1u0LtRGclSi/EHQ+F8YVq+HZJpXTsJeAmOmihma3GVbGKSZr+BRum+0YZSG4w+o4TOlYzw/4bLWS52MogZcwpjd+hemBbgXLuGU2ziKv2vEKCZFbEeA16II4x1WLI4mutDdCeh7+3aLzGLwDa49NxtsVYNjyNFF75JhCTCNA55e2YMiLz9Uq69IXe/mi5F7xUaFfhIqqLNyKBnKeEOzu3dYnc+8n3LjnQ+00PmkF05nx9kBn3UfV1kwQGh6QbyDmTtBP07rtUMyI14aeQqHjxsaVRdMnwj9Q2DjXRr8UDqESZF0rmK3pHCXS2fBhIzLE8tLVW5Heiba2pQRFMHMZW+KBE97FzcFh7is90Ait3T8enfcd/PWFPYoBejDAdjwxwOkezh5N5ZkYquEfDYuWrFi6zRFCktsruaAcA+xGtTf9oilBBzUqu8Ie+YFWH5me83xakcblJWdaW/D2rLJAJH3m6LFm8lBqyUgDX5t/etob6CpDuYHu5D1J3XINOj/+aLAcadq6qlh70PMZS3zYffUu3JlzaD2amlSHIT8b5YXFc=
file:
- release/*.tar.gz
- release/*.zip
on:
repo: cdr/code-server
tags: true
cache:
timeout: 1000
yarn: true
directories:
- source

View File

@ -1,57 +0,0 @@
FROM node:12.14.0
ARG tag
ARG githubToken
# Install VS Code's deps. These are the only two it seems we need.
RUN apt-get update && apt-get install -y \
libxkbfile-dev \
libsecret-1-dev
WORKDIR /src
COPY . .
RUN yarn \
&& DRONE_TAG="$tag" MINIFY=true STRIP_BIN_TARGET=true GITHUB_TOKEN="$githubToken" ./scripts/ci.bash \
&& rm -r /src/build \
&& rm -r /src/source
# We deploy with Ubuntu so that devs have a familiar environment.
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y \
openssl \
net-tools \
git \
locales \
sudo \
dumb-init \
vim \
curl \
wget \
&& rm -rf /var/lib/apt/lists/*
RUN locale-gen en_US.UTF-8
# We cannot use update-locale because docker will not use the env variables
# configured in /etc/default/locale so we need to set it manually.
ENV LC_ALL=en_US.UTF-8 \
SHELL=/bin/bash
RUN adduser --gecos '' --disabled-password coder && \
echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd
USER coder
# Create first so these directories will be owned by coder instead of root
# (workdir and mounting appear to both default to root).
RUN mkdir -p /home/coder/project
RUN mkdir -p /home/coder/.local/share/code-server
WORKDIR /home/coder/project
# This ensures we have a volume mounted even if the user forgot to do bind
# mount. So that they do not lose their data if they delete the container.
VOLUME [ "/home/coder/project" ]
COPY --from=0 /src/binaries/code-server /usr/local/bin/code-server
EXPOSE 8080
ENTRYPOINT ["dumb-init", "code-server", "--host", "0.0.0.0"]

37
ci/Dockerfile Normal file
View File

@ -0,0 +1,37 @@
FROM debian:10
RUN apt-get update
RUN apt-get install -y curl
ARG DOWNLOAD_URL=https://github.com/cdr/code-server/releases/download/2.1698/code-server2.1698-vsc1.41.1-linux-x86_64.tar.gz
RUN cd /tmp && curl -L "$DOWNLOAD_URL" | \
tar -xz && \
cp code-server*/code-server /usr/local/bin/code-server
# https://wiki.debian.org/Locale#Manually
RUN apt-get install -y locales
RUN sed -i "s/# en_US.UTF-8/en_US.UTF-8/" /etc/locale.gen
RUN locale-gen
ENV LANG=en_US.UTF-8
RUN chsh -s /bin/bash
ENV SHELL=/bin/bash
RUN apt-get install -y dumb-init sudo
RUN apt-get install -y man procps vim nano htop ssh git
RUN adduser --gecos '' --disabled-password coder && \
echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd
RUN curl -SsL https://github.com/boxboat/fixuid/releases/download/v0.4/fixuid-0.4-linux-amd64.tar.gz | tar -C /usr/local/bin -xzf - && \
chown root:root /usr/local/bin/fixuid && \
chmod 4755 /usr/local/bin/fixuid && \
mkdir -p /etc/fixuid && \
printf "user: coder\ngroup: coder\n" > /etc/fixuid/config.yml
RUN rm -rf /var/lib/apt/lists/*
EXPOSE 8080
USER coder
WORKDIR /home/coder
ENTRYPOINT ["dumb-init", "fixuid", "-q", "code-server", "--host", "0.0.0.0"]

11
ci/clean.sh Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail
main() {
git clean -xffd
git submodule foreach --recursive git clean -xffd
git submodule foreach --recursive git reset --hard
}
main "$@"

17
ci/fmt.sh Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -euo pipefail
main() {
shfmt -i 2 -w -s -sr $$(git ls-files "*.sh")
prettier --write --loglevel=warn $$(git ls-files "*.js" "*.ts" "*.tsx" "*.html" "*.json" "*.css" "*.md" "*.toml" "*.yaml" "*.yml")
if [[ "$CI" != "" && $$(git ls-files --other --modified --exclude-standard) != "" ]]; then
echo "Files need generation or are formatted incorrectly:"
git -c color.ui=always status | grep --color=no '\[31m'
echo "Please run the following locally:"
echo " make fmt"
exit 1
fi
}
main "$@"

12
ci/image/Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM node:12-buster
RUN apt-get update && apt-get install -y \
libxkbfile-dev \
libsecret-1-dev \
dumb-init
RUN curl -L https://github.com/mvdan/sh/releases/download/v3.0.1/shfmt_v3.0.1_linux_amd64 > /usr/local/bin/shfmt && chmod +x /usr/local/bin/shfmt
COPY entrypoint.sh /bin/entrypoint.sh
ENTRYPOINT ["dumb-init", "/bin/entrypoint.sh"]

5
ci/image/entrypoint.sh Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
eval "$@"

10
ci/lint.sh Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail
main() {
eslint --max-warnings=0 --fix $$(git ls-files "*.ts" "*.tsx" "*.js")
stylelint --fix $$(git ls-files "*.css")
}
main "$@"

6
ci/tsconfig.json Normal file
View File

@ -0,0 +1,6 @@
{
"extends": "../tsconfig.json",
"include": [
"./**/*.ts"
]
}

File diff suppressed because it is too large Load Diff

19
ci/vscode.sh Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -euo pipefail
# 1. Ensures VS Code is cloned.
# 2. Patches it.
# 3. Installs it.
main() {
cd "$(dirname "$0")/.."
git submodule update --init
# If the patch fails to apply, then it's likely already applied
yarn vscode:patch &>/dev/null || true
# Install VS Code dependencies.
(cd lib/vscode && yarn)
}
main "$@"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="200px" height="40px" viewBox="0 0 200 40" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 52.5 (67469) - http://www.bohemiancoding.com/sketch -->
<title>do-btn-blue-ghost</title>
<desc>Created with Sketch.</desc>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Partner-welcome-kit-Copy-3" transform="translate(-651.000000, -828.000000)">
<g id="do-btn-blue-ghost" transform="translate(651.000000, 828.000000)">
<rect id="Rectangle-Copy-4" stroke="#0069FF" x="0.5" y="0.5" width="199" height="39" rx="6"></rect>
<path d="M6,0 L47,0 L47,40 L6,40 C2.6862915,40 4.05812251e-16,37.3137085 0,34 L-8.8817842e-16,6 C-1.29399067e-15,2.6862915 2.6862915,6.08718376e-16 6,0 Z" id="Rectangle-Copy-5" fill="#0069FF"></path>
<g id="DO_Logo_horizontal_blue-Copy-3" transform="translate(13.000000, 10.000000)" fill="#FFFFFF">
<path d="M10.0098493,20 L10.0098493,16.1262429 C14.12457,16.1262429 17.2897398,12.0548452 15.7269372,7.74627862 C15.1334679,6.14538921 13.8674,4.86072487 12.2650328,4.28756693 C7.952489,2.72620566 3.87733294,5.88845634 3.87733294,9.99938223 C3.87733294,9.99938223 3.87733294,9.99938223 3.87733294,9.99938223 L0,9.99938223 C0,3.45747613 6.3303395,-1.64165309 13.1948014,0.492866119 C16.2017127,1.42177726 18.57559,3.81322933 19.5053586,6.79760341 C21.6418482,13.6754986 16.5577943,20 10.0098493,20 Z" id="XMLID_49_"></path>
<polygon id="XMLID_47_" points="9.52380952 16.1904762 5.71428571 16.1904762 5.71428571 12.3809524 5.71428571 12.3809524 9.52380952 12.3809524 9.52380952 12.3809524"></polygon>
<polygon id="XMLID_46_" points="6.66666667 19.047619 3.80952381 19.047619 3.80952381 19.047619 3.80952381 16.1904762 6.66666667 16.1904762"></polygon>
<polygon id="XMLID_45_" points="3.80952381 16.1904762 0.952380952 16.1904762 0.952380952 16.1904762 0.952380952 13.3333333 0.952380952 13.3333333 3.80952381 13.3333333 3.80952381 13.3333333"></polygon>
</g>
<!-- Modified to add GitHub font-family after DigitalOcean's font-family, otherwise it looks bad on GitHub -->
<text id="Create-a-Droplet-Copy-3" font-family="Sailec-Medium, Sailec, -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol" font-size="16" font-weight="400" fill="#0069FF">
<tspan x="58" y="26">Create a Droplet</tspan>
</text>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

View File

@ -1,75 +0,0 @@
# Installing code-server in your ChromiumOS/ChromeOS/CloudReady machine
This guide will show you how to install code-server into your CrOS machine.
## Using Crostini
One of the easier ways to run code-server is via
[Crostini](https://www.aboutchromebooks.com/tag/project-crostini/), the Linux
apps support feature in CrOS. Make sure you have enough RAM, HDD space and your
CPU has VT-x/ AMD-V support. If your chromebook has this, then you are
qualified to use Crostini.
If you are running R69, you might want to enable this on
[Chrome Flags](chrome://flags/#enable-experimental-crostini-ui).
If you run R72, however, this is already enabled for you.
After checking your prerequisites, follow the steps in [the self-host install guide](index.md)
on installing code-server. Once done, make sure code-server works by running
it. After running it, simply go to `penguin.linux.test:8080` to access
code-server. Now you should be greeted with this screen. If you did,
congratulations, you have installed code-server in your Chromebook!
![code-server on Chromebook](assets/cros.png)
Alternatively, if you ran code-server in another container and you need the IP
for that specific container, simply go to Termina's shell via `crosh` and type
`vsh termina`.
```bash
Loading extra module: /usr/share/crosh/dev.d/50-crosh.sh
Welcome to crosh, the Chrome OS developer shell.
If you got here by mistake, don't panic! Just close this tab and carry on.
Type 'help' for a list of commands.
If you want to customize the look/behavior, you can use the options page.
Load it by using the Ctrl+Shift+P keyboard shortcut.
crosh> vsh termina
(termina) chronos@localhost ~ $
```
While in termina, run `lxc list`. It should output the list of running containers.
```bash
(termina) chronos@localhost ~ $ lxc list
+---------|---------|-----------------------|------|------------|-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+---------|---------|-----------------------|------|------------|-----------+
| penguin | RUNNING | 100.115.92.199 (eth0) | | PERSISTENT | 0 |
+---------|---------|-----------------------|------|------------|-----------+
(termina) chronos@localhost ~ $
```
For this example, we show the default `penguin` container, which is exposed on
`eth0` at 100.115.92.199. Simply enter the IP of the container where the
code-server runs to Chrome.
## Using Crouton
[Crouton](https://github.com/dnschneid/crouton) is one of the old ways to get a
running full Linux via `chroot` on a Chromebook. To use crouton, enable
developer mode and go to `crosh`. This time, run `shell`, which should drop you
to `bash`.
Make sure you downloaded `crouton`, if so, go ahead and run it under
`~/Downloads`. After installing your chroot container via crouton, go ahead and
enter `enter-chroot` to enter your container.
Follow the instructions set in [the self-host install guide](index.md) to
install code-server. After that is done, run `code-server` and verify it works
by going to `localhost:8080`.
> At this point in writing, `localhost` seems to work in this method. However,
> the author is not sure if it applies still to newer Chromebooks.

View File

@ -1,73 +0,0 @@
# Set up instance
## EC2 on AWS
- Click **Launch Instance** from your [EC2 dashboard](https://console.aws.amazon.com/ec2/v2/home).
- Select the Ubuntu Server 18.04 LTS (HVM), SSD Volume Type
- Select an appropriate instance size (we recommend t2.medium/large, depending
on team size and number of repositories/languages enabled), then
**Next: Configure Instance Details**.
- Select **Next: ...** until you get to the **Configure Security Group** page,
then add a **Custom TCP Rule** rule with port range set to `8080` and source
set to "Anywhere".
> Rules with source of 0.0.0.0/0 allow all IP addresses to access your
> instance. We recommend setting [security group rules](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html?icmpid=docs_ec2_console)
> to allow access from known IP addresses only.
- Click **Launch**.
- You will be prompted to create a key pair.
- From the dropdown choose "create a new pair", give the key pair a name.
- Click **Download Key Pair** and store the file in a safe place.
- Click **Launch Instances**.
- Head to your [EC2 dashboard](https://console.aws.amazon.com/ec2/v2/home)
and choose instances from the left panel.
- In the description of your EC2 instance copy the public DNS (iPv4) address
using the copy to clipboard button.
- Open a terminal on your computer and SSH into your instance:
```
ssh -i ${path to key pair} ubuntu@${public address}
```
## DigitalOcean
[Open your DigitalOcean dashboard](https://cloud.digitalocean.com/droplets/new)
to create a new droplet
- **Choose an image -** Select the **Distributions** tab and then choose Ubuntu.
- **Choose a size -** We recommend at least 4GB RAM and 2 CPU, more depending
on team size and number of repositories/languages enabled.
- Launch your instance.
- Open a terminal on your computer and SSH into your instance:
```
ssh root@${instance ip}
```
## Google Cloud
> Pre-requisite: Set up the [Google Cloud SDK](https://cloud.google.com/sdk/docs/)
> on your local machine
- [Open your Google Cloud console](https://console.cloud.google.com/compute/instances)
to create a new VM instance and click **Create Instance**.
- Choose an appropriate machine type (we recommend 2 vCPU and 7.5 GB RAM, more
depending on team size and number of repositories/languages enabled).
- Choose Ubuntu 16.04 LTS as your boot disk.
- Expand the "Management, security, disks, networking, sole tenancy" section,
go to the "Networking" tab, then under network tags add "code-server".
- Create your VM, and **take note** of its public IP address.
- Visit "VPC network" in the console and go to "Firewall rules". Create a new
firewall rule called "http-8080". Under "Target tags" add "code-server", and
under "Protocols and ports" tick "Specified protocols and ports" and "tcp".
Beside "tcp", add "8080", then create the rule.
- Open a terminal on your computer and SSH into your Google Cloud VM:
```
gcloud compute ssh --zone ${region} ${instance name}
```
# Run code-server
- Download the latest code-server release from the
[releases page](https://github.com/cdr/code-server/releases/latest)
to the instance, extract the file, then run the code-server binary:
```
wget https://github.com/cdr/code-server/releases/download/{version}/code-server{version}-linux-x64.tar.gz
tar -xvzf code-server{version}-linux-x64.tar.gz
cd code-server{version}-linux-x64
./code-server
```
- Open your browser and visit http://$public_ip:8080/ where `$public_ip` is
your instance's public IP address.
- For long-term use, set up a systemd service to run code-server.

View File

@ -1,15 +0,0 @@
# Fail2Ban filter for code-server
[Definition]
failregex = ^Failed login attempt\s+{\"remoteAddress\":\"<HOST>\"
# Use this instead for proxies (ensure the proxy is configured to send the
# X-Forwarded-For header).
# failregex = ^Failed login attempt\s+{\"xForwardedFor\":\"<HOST>\"
ignoreregex =
datepattern = "timestamp":{EPOCH}}$
# Author: Dean Sheather

View File

@ -1,73 +0,0 @@
apiVersion: v1
kind: Namespace
metadata:
name: code-server
---
apiVersion: v1
kind: Service
metadata:
name: code-server
namespace: code-server
spec:
ports:
- port: 8080
name: https
protocol: TCP
selector:
app: code-server
type: ClusterIP
---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: gp2
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: kubernetes.io/aws-ebs
parameters:
type: gp2
fsType: ext4
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: code-store
namespace: code-server
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 60Gi
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: code-server
name: code-server
namespace: code-server
spec:
selector:
matchLabels:
app: code-server
replicas: 1
template:
metadata:
labels:
app: code-server
spec:
containers:
- image: codercom/code-server:v2
imagePullPolicy: Always
name: code-servery
ports:
- containerPort: 8080
name: https
volumeMounts:
- name: code-server-storage
mountPath: /go/src
volumes:
- name: code-server-storage
persistentVolumeClaim:
claimName: code-store

View File

@ -1,43 +0,0 @@
apiVersion: v1
kind: Namespace
metadata:
name: code-server
---
apiVersion: v1
kind: Service
metadata:
name: code-server
namespace: code-server
spec:
ports:
- port: 8080
name: https
protocol: TCP
selector:
app: code-server
type: ClusterIP
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: code-server
name: code-server
namespace: code-server
spec:
selector:
matchLabels:
app: code-server
replicas: 1
template:
metadata:
labels:
app: code-server
spec:
containers:
- image: codercom/code-server:v2
imagePullPolicy: Always
name: code-server
ports:
- containerPort: 8080
name: https

View File

@ -1,35 +0,0 @@
# Protecting code-server from bruteforce attempts
code-server outputs all failed login attempts, along with the IP address,
provided password, user agent and timestamp by default.
When using a reverse proxy such as Nginx or Apache, the remote address may
appear to be `127.0.0.1` or a similar address so `X-Forwarded-For` should be
used instead. Ensure that you are setting this value in your reverse proxy:
Nginx:
```
location / {
...
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
...
}
```
Apache:
```
<VirtualEnv>
...
SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
...
</VirtualEnv>
```
It is extremely important that you ensure that your code-server instance is not
accessible from the internet (use localhost or block it in your firewall).
## Fail2Ban
Fail2Ban allows for automatically banning and logging repeated failed
authentication attempts for many applications through regex filters. A working
filter for code-server can be found in `./examples/fail2ban.conf`. Once this
is installed and configured correctly, repeated failed login attempts should
automatically be banned from connecting to your server.

View File

@ -1,98 +0,0 @@
# Quickstart Guide
1. Visit the [releases page](https://github.com/cdr/code-server/releases) and
download the latest binary for your operating system.
2. Unpack the downloaded file then run the binary.
3. In your browser navigate to `localhost:8080`.
## Usage
Run `code-server --help` to view available options.
### Nginx Reverse Proxy
The trailing slashes are important.
```
server {
listen 80;
listen [::]:80;
server_name code.example.com code.example.org;
location /some/path/ { # Or / if hosting at the root.
proxy_pass http://localhost:8080/;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;
}
}
```
### Apache Reverse Proxy
```
<VirtualHost *:80>
ServerName code.example.com
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://localhost:8080/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://localhost:8080/$1 [P,L]
ProxyRequests off
ProxyPass / http://localhost:8080/ nocanon
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
```
### Run automatically at startup
In some cases you might need to run code-server automatically once the host starts. You may use your local init service to do so.
#### Systemd
```ini
[Unit]
Description=Code Server IDE
After=network.target
[Service]
Type=simple
User=<USER>
EnvironmentFile=$HOME/.profile
WorkingDirectory=$HOME
Restart=on-failure
RestartSec=10
ExecStart=<PATH TO BINARY> $(pwd)
StandardOutput=file:/var/log/code-server-output.log
StandardError=file:/var/log/code-server-error.log
[Install]
WantedBy=multi-user.target
```
#### OpenRC
```sh
#!/sbin/openrc-run
depend() {
after net-online
need net
}
supervisor=supervise-daemon
name="code-server"
command="/opt/cdr/code-server"
command_args=""
pidfile="/var/run/cdr.pid"
respawn_delay=5
set -o allexport
if [ -f /etc/environment ]; then source /etc/environment; fi
set +o allexport
```
#### Kubernetes/Docker
Make sure you set your restart policy to always - this will ensure your container starts as the daemon starts.

View File

@ -1,13 +0,0 @@
version: "3"
services:
code-server:
container_name: code-server
image: codercom/code-server
ports:
- "8080:8080"
volumes:
- "${PWD}:/home/coder/project"
- "${HOME}/.local/share/code-server:/home/coder/.local/share/code-server"
environment:
PASSWORD: ${PASSWORD}

View File

@ -3,19 +3,19 @@
"license": "MIT",
"version": "2.1.0",
"scripts": {
"i": "yarn install --ignore-scripts",
"preinstall": "./scripts/preinstall.sh",
"postinstall": "./scripts/postinstall.sh",
"patch:generate": "cd ./lib/vscode && git diff HEAD > ../../scripts/vscode.patch",
"patch:apply": "cd ./lib/vscode && git apply ../../scripts/vscode.patch",
"clean": "ci/clean.sh",
"vscode": "ci/vscode.sh",
"vscode:patch": "cd ./lib/vscode && git apply ../../ci/vscode.patch",
"vscode:diff": "cd ./lib/vscode && git diff HEAD > ../../ci/vscode.patch",
"test": "mocha -r ts-node/register ./test/*.test.ts",
"test:build": "./scripts/test.sh",
"lint:js": "eslint src test scripts --ext .ts,.tsx",
"lint:css": "stylelint 'src/**/*.css'",
"lint": "./scripts/lint.sh",
"watch": "yarn runner watch",
"runner": "cd ./scripts && node --max-old-space-size=32384 -r ts-node/register ./build.ts",
"lint": "ci/lint.sh",
"fmt": "ci/fmt.sh",
"runner": "cd ./scripts && NODE_OPTIONS=--max_old_space_size=32384 ts-node ./build.ts",
"build": "yarn runner build",
"watch": "yarn runner watch",
"binary": "yarn runner binary",
"package": "yarn runner package"
},

View File

@ -1,66 +0,0 @@
#!/usr/bin/env sh
# cacher.sh -- Restore and rebuild cache.
# Cache paths are designed to work with multi-arch builds and are organized
# based on the branch or tag. The master branch cache is used as a fallback.
# This will download and package the cache but it will not upload it.
set -eu
# Try restoring from each argument in turn until we get something.
restore() {
for branch in "$@" ; do
if [ -n "$branch" ] ; then
cache_path="https://codesrv-ci.cdr.sh/cache/$branch/$tar.tar.gz"
if wget "$cache_path" ; then
tar xzvf "$tar.tar.gz"
break
fi
fi
done
}
# We need to cache the built-in extensions and Node modules. Everything inside
# the cache-upload directory will be uploaded as-is to the code-server bucket.
package() {
mkdir -p "cache-upload/cache/$1"
tar czfv "cache-upload/cache/$1/$tar.tar.gz" node_modules yarn-cache \
lib/vscode/.build \
lib/vscode/node_modules
}
main() {
cd "$(dirname "$0")/.."
# Get the branch for this build.
branch=${DRONE_BRANCH:-${DRONE_SOURCE_BRANCH:-${DRONE_TAG:-}}}
# The cache will be named based on the arch, platform, and libc.
arch=$DRONE_STAGE_ARCH
platform=${PLATFORM:-linux}
case $DRONE_STAGE_NAME in
*alpine*) libc=musl ;;
* ) libc=glibc ;;
esac
tar="$platform-$arch-$libc"
# The action is determined by the name of the step.
case $DRONE_STEP_NAME in
*restore*)
# Sub-modules must be pulled first since extracting the cache directories
# will prevent git from cloning into them.
git submodule update --init
restore "$branch" "$DRONE_REPO_BRANCH"
# Now make sure the pulled Node modules are up to date.
YARN_CACHE_FOLDER="$(pwd)/yarn-cache"
export YARN_CACHE_FOLDER
yarn
;;
*rebuild*|*package*) package "$branch" ;;
*) exit 1 ;;
esac
}
main "$@"

View File

@ -1,39 +0,0 @@
# We deploy with Ubuntu so that devs have a familiar environment.
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y \
openssl \
net-tools \
git \
locales \
sudo \
dumb-init \
vim \
curl \
wget
RUN locale-gen en_US.UTF-8
# We cannot use update-locale because docker will not use the env variables
# configured in /etc/default/locale so we need to set it manually.
ENV LC_ALL=en_US.UTF-8 \
SHELL=/bin/bash
RUN adduser --gecos '' --disabled-password coder && \
echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd
USER coder
# Create first so these directories will be owned by coder instead of root
# (workdir and mounting appear to both default to root).
RUN mkdir -p /home/coder/project
RUN mkdir -p /home/coder/.local/share/code-server
WORKDIR /home/coder/project
# This ensures we have a volume mounted even if the user forgot to do bind
# mount. So that they do not lose their data if they delete the container.
VOLUME [ "/home/coder/project" ]
COPY ./binaries/code-server* /usr/local/bin/code-server
EXPOSE 8080
ENTRYPOINT ["dumb-init", "code-server", "--host", "0.0.0.0"]

View File

@ -1,9 +0,0 @@
#!/usr/bin/env bash
# code-server.sh -- Run code-server with the bundled Node binary.
main() {
cd "$(dirname "$0")" || exit 1
./node ./out/node/entry.js "$@"
}
main "$@"

View File

@ -1,11 +0,0 @@
#!/usr/bin/env sh
# lint.sh -- Lint CSS and JS files.
set -eu
main() {
yarn lint:css "$@"
yarn lint:js "$@"
}
main "$@"

View File

@ -1,10 +0,0 @@
#!/usr/bin/env sh
# postinstall.sh - Does nothing at the moment.
set -eu
main() {
cd "$(dirname "${0}")/.."
}
main "$@"

View File

@ -1,21 +0,0 @@
#!/usr/bin/env sh
# preinstall.sh -- Prepare VS Code.
set -eu
main() {
cd "$(dirname "${0}")/.."
# Ensure submodules are cloned and up to date.
git submodule update --init
# Try patching but don't worry too much if it fails. It's possible VS Code has
# already been patched.
yarn patch:apply || echo "Unable to patch; assuming already patched"
# Install VS Code dependencies.
cd ./lib/vscode
yarn
}
main "$@"

View File

@ -1,19 +0,0 @@
#!/usr/bin/env sh
# test.sh -- Simple build test.
set -eu
main() {
cd "$(dirname "$0")/.."
# The main goal here is to ensure that the build fully completed and the
# result looks usable.
version=$(node ./build/out/node/entry.js --version --json)
echo "Got '$version' for the version"
case $version in
"{ codeServer":*) exit 0 ;;
*) exit 1 ;;
esac
}
main "$@"

View File

@ -1,21 +0,0 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"strict": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"forceConsistentCasingInFileNames": true,
"outDir": "./out",
"declaration": true,
"experimentalDecorators": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"sourceMap": true
},
"include": [
"./**/*.ts"
]
}