Skip to content

Adding ENTRYPOINT to omit code-server at the CLI. #155

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

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
994531d
Add task for packaging release (#6)
code-asher Mar 7, 2019
e99f8ab
Fix spelling error (#46)
philippgille Mar 7, 2019
e20b79b
Generate secure passwords, fixes issue #26 (#51)
MichaelDesantis Mar 7, 2019
ac56fca
Remove unused markup from password page (#49)
MichaelDesantis Mar 7, 2019
17267bd
Add Dockerfile and some cleanup (#57)
nhooyr Mar 7, 2019
87d2e22
Open localhost URL with --open (#28)
fand Mar 7, 2019
3d654a8
Resolve paths
code-asher Mar 7, 2019
8e68411
Update example docker command port bind options (#88)
Omeryl Mar 7, 2019
fba3fe5
Dockerfile: cleanup and add en_US.UTF-8 locale
nhooyr Mar 7, 2019
14f1230
Merge pull request #98 from nhooyr/docker
nhooyr Mar 7, 2019
8e5f288
Updated current args available for passing in docs (#105)
Omeryl Mar 7, 2019
231cdec
Update known issues in readme with better wording
kylecarbs Mar 7, 2019
c8afb79
Merge branch 'master' of github.com:codercom/code-server
kylecarbs Mar 7, 2019
96175d3
Handle arch in dockerfile and add PR template (#109)
nhooyr Mar 7, 2019
9f4212e
inital -> initial (#135)
ss18 Mar 8, 2019
5c435a3
Update grammar on README (#139)
jpinnix Mar 8, 2019
36c05ed
Feature/1.32.0 update (#117)
code-asher Mar 8, 2019
e418ecf
Improve .dockerignore (#111)
Mar 8, 2019
3e9d86e
ci: enable travis npm cache (#110)
nhooyr Mar 8, 2019
8bab787
Move upx compression behind an env flag
code-asher Mar 8, 2019
cded51f
Add back web class
code-asher Mar 8, 2019
58c2f78
Added ENTRYPOINT to omit full command at launch.
ay-b Mar 9, 2019
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
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Dockerfile
# Docs
doc/
# GitHub stuff
.github
.gitignore
.travis.yml
LICENSE
README.md
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* @coderasher @kylecarbs
* @coderasher @kylecarbs
Dockerfile @nhooyr
6 changes: 6 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- 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?

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules
dist
out
.DS_Store
release
21 changes: 13 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
language: node_js
node_js:
- 8.9.3
- 8.15.0
env:
- VERSION="1.32.0-$TRAVIS_BUILD_NUMBER"
matrix:
include:
- os: linux
Expand All @@ -12,22 +14,25 @@ before_install:
script:
- scripts/build.sh
before_deploy:
- export TRAVIS_TAG="1.31.1-$TRAVIS_BUILD_NUMBER"
- echo "$TRAVIS_TAG" "$TRAVIS_COMMIT"
- echo "$VERSION" "$TRAVIS_COMMIT"
- git config --local user.name "$USER_NAME"
- git config --local user.email "$USER_EMAIL"
- git tag "$TRAVIS_TAG" "$TRAVIS_COMMIT"
- git tag "$VERSION" "$TRAVIS_COMMIT"
- yarn task package "$VERSION"
deploy:
provider: releases
file_glob: true
draft: true
tag_name: $TRAVIS_TAG
target_commitish: $TRAVIS_COMMIT
name: $TRAVIS_TAG
tag_name: "$VERSION"
target_commitish: "$TRAVIS_COMMIT"
name: "$VERSION"
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: packages/server/cli-*
file:
- release/*.tar.gz
- release/*.zip
on:
repo: codercom/code-server
branch: master
cache: yarn
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM node:8.15.0

# 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

# Ensure latest yarn.
RUN npm install -g [email protected]

WORKDIR /src
COPY . .

# In the future, we can use https://github.com/yarnpkg/rfcs/pull/53 to make yarn use the node_modules
# directly which should be fast as it is slow because it populates its own cache every time.
RUN yarn && yarn task build:server:binary

# We deploy with ubuntu so that devs have a familiar environemnt.
FROM ubuntu:18.10
WORKDIR /root/project
COPY --from=0 /src/packages/server/cli-linux-x64 /usr/local/bin/code-server
EXPOSE 8443
RUN apt-get update && apt-get install -y \
openssl \
net-tools
RUN apt-get install -y locales && \
locale-gen en_US.UTF-8
# We unfortunately 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 LANG=en_US.UTF-8
# Unfortunately `.` does not work with code-server.
ENTRYPOINT ["code-server"]
CMD ["$PWD"]
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,37 @@

`code-server` is [VS Code](https://github.com/Microsoft/vscode) running on a remote server, accessible through the browser.

Try it out:
```bash
docker run -p 127.0.0.1:8443:8443 -v "${PWD}:/root/project" codercom/code-server code-server --allow-http --no-auth
```

- Code on your Chromebook, tablet, and laptop with a consistent dev environment.
- If you have a Windows or Mac workstation, more easily develop for Linux.
- Take advantage of large cloud servers to speed up tests, compilations, downloads, and more.
- Preserve battery life when you're on the go.
- All intensive computation is ran on your server.
- All intensive computation runs on your server.
- You're no longer running excess instances of Chrome.

![Screenshot](/doc/assets/ide.png)

## Getting Started

### Hosted

[Try `code-server` now](https://coder.com/signup) for free at coder.com.

**OR**
### Docker

See docker oneliner mentioned above. Dockerfile is at [/Dockerfile](/Dockerfile).

### Binaries

1. [Download a binary](https://github.com/codercom/code-server/releases) (Linux and OSX supported. Windows coming soon)
2. Start the binary with the project directory as the first argument

```
code-server <inital directory to open>
code-server <initial directory to open>
```
> You will be prompted to enter the password shown in the CLI
`code-server` should now be running at https://localhost:8443.
Expand All @@ -43,7 +54,7 @@ How to [secure your setup](/doc/security/ssl.md).

### Known Issues

- Debugging extensions doesnt work.
- Creating custom VS Code extensions and debugging them doesn't work.

### Future

Expand Down
44 changes: 36 additions & 8 deletions build/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,24 @@ const buildServerBinaryPackage = register("build:server:binary:package", async (
});

const dependencyNexeBinary = register("dependency:nexe", async (runner) => {
if (os.platform() === "linux") {
if (os.platform() === "linux" && process.env.COMPRESS === "true") {
// Download the nexe binary so we can compress it before nexe runs. If we
// don't want compression we don't need to do anything since nexe will take
// care of getting the binary.
const nexeDir = path.join(os.homedir(), ".nexe");
const targetBinaryName = `${os.platform()}-${os.arch()}-${process.version.substr(1)}`;
const targetBinaryPath = path.join(nexeDir, targetBinaryName);
if (!fs.existsSync(targetBinaryPath)) {
/**
* We create a binary with nexe
* so we can compress it
*/
fse.mkdirpSync(nexeDir);
runner.cwd = nexeDir;
await runner.execute("wget", [`https://github.com/nexe/nexe/releases/download/v3.0.0-beta.15/${targetBinaryName}`]);
await runner.execute("chmod", ["+x", targetBinaryPath]);
}
// Compress with upx if it doesn't already look compressed.
if (fs.statSync(targetBinaryPath).size >= 20000000) {
// Compress w/ upx
// It needs to be executable for upx to work, which it might not be if
// nexe downloaded it.
fs.chmodSync(targetBinaryPath, "755");
const upxFolder = path.join(os.tmpdir(), "upx");
const upxBinary = path.join(upxFolder, "upx");
if (!fs.existsSync(upxBinary)) {
Expand Down Expand Up @@ -194,7 +196,7 @@ const buildDefaultExtensions = register("build:default-extensions", async (runne
if (!fs.existsSync(defaultExtensionsPath)) {
await copyForDefaultExtensions();
runner.cwd = extDirPath;
const resp = await runner.execute(isWin ? "npx.cmd" : "npx", [isWin ? "gulp.cmd" : "gulp", "vscode-linux-x64"]);
const resp = await runner.execute(isWin ? "npx.cmd" : "npx", [isWin ? "gulp.cmd" : "gulp", "vscode-linux-x64", "--max-old-space-size=32384"]);
if (resp.exitCode !== 0) {
throw new Error(`Failed to build default extensions: ${resp.stderr}`);
}
Expand Down Expand Up @@ -224,7 +226,7 @@ const ensureCloned = register("vscode:clone", async (runner) => {
}

runner.cwd = vscodePath;
const checkout = await runner.execute("git", ["checkout", "tags/1.31.1"]);
const checkout = await runner.execute("git", ["checkout", "tags/1.32.0"]);
if (checkout.exitCode !== 0) {
throw new Error(`Failed to checkout: ${checkout.stderr}`);
}
Expand Down Expand Up @@ -260,4 +262,30 @@ const ensurePatched = register("vscode:patch", async (runner) => {
}
});

register("package", async (runner, releaseTag) => {
if (!releaseTag) {
throw new Error("Please specify the release tag.");
}

const releasePath = path.resolve(__dirname, "../release");

const archiveName = `code-server-${releaseTag}-${os.platform()}-${os.arch()}`;
const archiveDir = path.join(releasePath, archiveName);
fse.removeSync(archiveDir);
fse.mkdirpSync(archiveDir);

const binaryPath = path.join(__dirname, `../packages/server/cli-${os.platform()}-${os.arch()}`);
const binaryDestination = path.join(archiveDir, "code-server");
fse.copySync(binaryPath, binaryDestination);
fs.chmodSync(binaryDestination, "755");
["README.md", "LICENSE"].forEach((fileName) => {
fse.copySync(path.resolve(__dirname, `../${fileName}`), path.join(archiveDir, fileName));
});

runner.cwd = releasePath;
await os.platform() === "linux"
? runner.execute("tar", ["-cvzf", `${archiveName}.tar.gz`, `${archiveName}`])
: runner.execute("zip", ["-r", `${archiveName}.zip`, `${archiveName}`]);
});

run();
10 changes: 6 additions & 4 deletions doc/self-hosted/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,26 @@ OPTIONS
-o, --open Open in browser on startup
-p, --port=port [default: 8443] Port to bind on
-v, --version show CLI version
--allow-http
--cert=cert
--cert-key=cert-key
--password=password
--help show CLI help
--no-auth
--password=password
```

### Data directory
Use `code-server -d (path/to/directory)` or `code-server --data-dir=(path/to/directory)`, excluding the parentheses to specify the root folder that VS Code will start in

### Host
By default, code-server will use `0.0.0.0` as it's address. This can be changed by using `code-server -h` or `code-server --host=` followed by the address you want to use.
By default, code-server will use `0.0.0.0` as its address. This can be changed by using `code-server -h` or `code-server --host=` followed by the address you want to use.
> Example: `code-server -h 127.0.0.1`

### Open
You can have the server automatically open the VS Code in your browser on startup by using the `code server -o` or `code-server --open` flags

### Port
By default, code-server will use `8443` as it's port. This can be changed by using `code-server -p` or `code-server --port=` followed by the port you want to use.
By default, code-server will use `8443` as its port. This can be changed by using `code-server -p` or `code-server --port=` followed by the port you want to use.
> Example: `code-server -p 9000`

### Cert and Cert Key
Expand All @@ -73,4 +75,4 @@ OPTIONS
> To ensure the connection between you and your server is encrypted view our guide on [securing your setup](../security/ssl.md)

### Help
Use `code-server -h` or `code-server --help` to view the usage for the cli. This is also shown at the beginning of this section.
Use `code-server -h` or `code-server --help` to view the usage for the cli. This is also shown at the beginning of this section.
15 changes: 0 additions & 15 deletions packages/app/browser/src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,6 @@ <h2 class="subtitle">
<label class="mdc-floating-label" for="password">Password</label>
<div class="mdc-line-ripple"></div>
</div>
<div class="mdc-text-field-helper-line">
<div class="mdc-text-field-helper-text">helper text</div>
</div>
<div class="mdc-form-field">
<div class="mdc-checkbox">
<input type="checkbox" class="mdc-checkbox__native-control" id="remember" />
<div class="mdc-checkbox__background">
<svg class="mdc-checkbox__checkmark" viewBox="0 0 24 24">
<path class="mdc-checkbox__checkmark-path" fill="none" d="M1.73,12.91 8.1,19.28 22.79,4.59" />
</svg>
<div class="mdc-checkbox__mixedmark"></div>
</div>
</div>
<label for="remember">Remember Me</label>
</div>
<button id="submit" class="mdc-button mdc-button--unelevated">
<span class="mdc-button__label">Enter IDE</span>
</button>
Expand Down
2 changes: 1 addition & 1 deletion packages/app/common/src/containers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export class Server extends React.Component<ServerProps, {
if (xhr.status === 200) {
this.setState({
status: "Online",
version: "v1.31.0",
version: process.env.VERSION,
});
} else {
this.setState({
Expand Down
26 changes: 21 additions & 5 deletions packages/runner/src/runner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as cp from "child_process";
import { logger, Logger, field, time } from "@coder/logger";
import {field, Logger, logger, time} from "@coder/logger";

export interface CommandResult {
readonly exitCode: number;
Expand All @@ -9,7 +9,9 @@ export interface CommandResult {

const execute = (command: string, args: string[] = [], options: cp.SpawnOptions, logger: Logger): Promise<CommandResult> => {
let resolve: (result: CommandResult) => void;
const prom = new Promise<CommandResult>(res => resolve = res);
const prom = new Promise<CommandResult>((res): void => {
resolve = res;
});

const stdout: string[] = [];
const stderr: string[] = [];
Expand Down Expand Up @@ -40,10 +42,12 @@ const execute = (command: string, args: string[] = [], options: cp.SpawnOptions,
return prom;
};

export type TaskFunction = (runner: Runner) => void | Promise<void>;
// tslint:disable-next-line no-any
export type TaskFunction = (runner: Runner, ...args: any[]) => void | Promise<void>;

export interface Runner {
cwd: string;

execute(command: string, args?: string[], env?: object): Promise<CommandResult>;
}

Expand Down Expand Up @@ -90,12 +94,24 @@ export const run = (name: string = process.argv[2]): void | Promise<void> => {
cwd = path;
},
execute(command: string, args: string[] = [], env?: object): Promise<CommandResult> {
return execute(command, args, {
const prom = execute(command, args, {
cwd,
env: env as NodeJS.ProcessEnv,
}, log);

return prom.then((result: CommandResult) => {
if (result.exitCode != 0) {
log.error("failed",
field("exitCode", result.exitCode),
field("stdout", result.stdout),
field("stderr", result.stderr)
);
}

return result;
});
},
});
}, ...process.argv.slice(3));

if (prom) {
activated.set(name, prom);
Expand Down
4 changes: 3 additions & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"files": [],
"scripts": {
"start": "node --max-old-space-size=32384 --require ts-node/register --require tsconfig-paths/register src/cli.ts",
"build": "rm -rf ./out && cross-env CLI=true UV_THREADPOOL_SIZE=100 node --max-old-space-size=32384 ../../node_modules/webpack/bin/webpack.js --config ./webpack.config.js",
"build": "rm -rf ./out && ../../node_modules/.bin/cross-env CLI=true UV_THREADPOOL_SIZE=100 node --max-old-space-size=32384 ../../node_modules/webpack/bin/webpack.js --config ./webpack.config.js",
"build:nexe": "node scripts/nexe.js"
},
"dependencies": {
Expand All @@ -26,10 +26,12 @@
"@types/express": "^4.16.0",
"@types/fs-extra": "^5.0.4",
"@types/mime-types": "^2.1.0",
"@types/opn": "^5.1.0",
"@types/pem": "^1.9.4",
"@types/ws": "^6.0.1",
"fs-extra": "^7.0.1",
"nexe": "^2.0.0-rc.34",
"opn": "^5.4.0",
"string-replace-webpack-plugin": "^0.1.3",
"ts-node": "^7.0.1",
"tsconfig-paths": "^3.7.0",
Expand Down
Loading