Skip to content

Commit 17267bd

Browse files
nhooyrkylecarbs
authored andcommitted
Add Dockerfile and some cleanup (#57)
1 parent ac56fca commit 17267bd

File tree

5 files changed

+57
-5
lines changed

5 files changed

+57
-5
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Dockerfile

Dockerfile

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM node:8.15.0
2+
3+
# Install VS Code's deps. These are the only two it seems we need.
4+
RUN apt-get update
5+
RUN apt-get install -y libxkbfile-dev libsecret-1-dev
6+
7+
# Ensure latest yarn.
8+
RUN npm install -g yarn
9+
10+
# In the future, we can use https://github.com/yarnpkg/rfcs/pull/53 to make it use the node_modules
11+
# directly which should be faster.
12+
WORKDIR /src
13+
COPY . .
14+
RUN yarn
15+
RUN yarn task build:server:binary
16+
17+
# We deploy with ubuntu so that devs have a familiar environemnt.
18+
FROM ubuntu:18.10
19+
RUN apt-get update
20+
RUN apt-get install -y openssl
21+
RUN apt-get install -y net-tools
22+
WORKDIR /root/project
23+
COPY --from=0 /src/packages/server/cli-linux /usr/local/bin/code-server
24+
EXPOSE 8443
25+
# Unfortunately `.` does not work with code-server.
26+
CMD code-server $PWD

README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

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

10+
Try it out:
11+
```bash
12+
docker run -p localhost:8443:8443 -v "${PWD}:/root/project" codercom/code-server code-server --allow-http --no-auth
13+
```
14+
1015
- Code on your Chromebook, tablet, and laptop with a consistent dev environment.
1116
- If you have a Windows or Mac workstation, more easily develop for Linux.
1217
- Take advantage of large cloud servers to speed up tests, compilations, downloads, and more.
@@ -18,9 +23,15 @@
1823

1924
## Getting Started
2025

26+
### Hosted
27+
2128
[Try `code-server` now](https://coder.com/signup) for free at coder.com.
2229

23-
**OR**
30+
### Docker
31+
32+
See docker oneliner mentioned above. Dockerfile is at [/Dockerfile](/Dockerfile).
33+
34+
### Binaries
2435

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

packages/runner/src/runner.ts

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as cp from "child_process";
2-
import { logger, Logger, field, time } from "@coder/logger";
2+
import {field, Logger, logger, time} from "@coder/logger";
33

44
export interface CommandResult {
55
readonly exitCode: number;
@@ -9,7 +9,9 @@ export interface CommandResult {
99

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

1416
const stdout: string[] = [];
1517
const stderr: string[] = [];
@@ -45,6 +47,7 @@ export type TaskFunction = (runner: Runner, ...args: any[]) => void | Promise<vo
4547

4648
export interface Runner {
4749
cwd: string;
50+
4851
execute(command: string, args?: string[], env?: object): Promise<CommandResult>;
4952
}
5053

@@ -91,10 +94,22 @@ export const run = (name: string = process.argv[2]): void | Promise<void> => {
9194
cwd = path;
9295
},
9396
execute(command: string, args: string[] = [], env?: object): Promise<CommandResult> {
94-
return execute(command, args, {
97+
const prom = execute(command, args, {
9598
cwd,
9699
env: env as NodeJS.ProcessEnv,
97100
}, log);
101+
102+
return prom.then((result: CommandResult) => {
103+
if (result.exitCode != 0) {
104+
log.error("failed",
105+
field("exitCode", result.exitCode),
106+
field("stdout", result.stdout),
107+
field("stderr", result.stderr)
108+
);
109+
}
110+
111+
return result;
112+
});
98113
},
99114
}, ...process.argv.slice(3));
100115

scripts/build.sh

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
22
set -e
33

4-
npm install -g cross-env
54
yarn task build:server:binary

0 commit comments

Comments
 (0)