Skip to content

Commit 97c73e6

Browse files
committed
Merge remote-tracking branch 'upstream/master'
* upstream/master: Update VS Code to 1.33.0 (coder#445) Reduce layers in Dockerfile Update README.md Significantly improve the Dockerfile Use an init system fix: slap adduser into another RUN feat: user-mode docker Fix sending dates through the protocol Remove non-working menu items Update @coder/nbin. Fixes UI state saves Build for production in Docker Update @coder/nbin
2 parents 6eb70ca + a1136b3 commit 97c73e6

35 files changed

+694
-348
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ env:
55
global:
66
secure: gf/3J6XEFhEbaWesAaGtjvcMCmt07ztiIzHPzJuZXp5GIxImmZJk+F1ZNWSYcw2X7jcpyj20NvWUigX7FvzRE5L7LPEbzNugVLYHjw7YSzqtAacMnmOYmMnhjzed8mWmGjwEKiDy1qWQq/b+2GWuR5LH74/pEYF0/3M5XwEvQFGleZ1CVdemTeHBgjvAye6jBtOvJXijEprfiFbaNvWLgecwBtIlW76J9t+SEPWGe29nMNvMJl6rYvsT8sTnsTc2tL2v6kOpSTb3KgIyGPSajVJQ8v2JjlDIVUMPRObVfHQ979B3WkMfkL+zuy9rbxXAT/FDZwuV15nN33OoONDl+uql200zpBk6Co7SQEanH1bUu1SiyowQ3dH5cYm+dOd+Xep06e/79UjzAyw08ok6nqHEraotwZUjh0wILiaX4EU72x1apyDPxCnFUUyKpH7MMxI/OUMMSrVOThBLJS+ZcRCQ3EPL8yEHwJ2wKfB6xnbaX/ctUhcSi15GcC5ZyfS12KHOwHgeasheKvOSjrzZV1pxVn+7BG8sr/LwnzUbC7CiBoAYzv/9e+kfVXhgIdRq75zRltJLVQQQU9Bk32iOjprxiK8XO5VBfwGKCtMGTrBbb8Q1sXgTOyoxvfR5hIKlnPu5gF4mCsCt9Jll496pzQnKhzEvTt3SM/02/5YpQjw=
77
matrix:
8-
- VSCODE_VERSION="1.32.0" MAJOR_VERSION="1" VERSION="$MAJOR_VERSION.$TRAVIS_BUILD_NUMBER-vsc$VSCODE_VERSION"
8+
- VSCODE_VERSION="1.33.0" MAJOR_VERSION="1" VERSION="$MAJOR_VERSION.$TRAVIS_BUILD_NUMBER-vsc$VSCODE_VERSION"
99
matrix:
1010
include:
1111
- os: linux

Dockerfile

+20-9
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,33 @@ COPY . .
1313

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

1818
# We deploy with ubuntu so that devs have a familiar environment.
19-
FROM ubuntu:18.10
20-
WORKDIR /root/project
21-
COPY --from=0 /src/packages/server/cli-linux-x64 /usr/local/bin/code-server
22-
EXPOSE 8443
19+
FROM ubuntu:18.04
2320

2421
RUN apt-get update && apt-get install -y \
2522
openssl \
2623
net-tools \
2724
git \
28-
locales
25+
locales \
26+
sudo \
27+
dumb-init
28+
2929
RUN locale-gen en_US.UTF-8
3030
# We unfortunately cannot use update-locale because docker will not use the env variables
3131
# configured in /etc/default/locale so we need to set it manually.
32-
ENV LANG=en_US.UTF-8
33-
ENV LC_ALL=en_US.UTF-8
34-
ENTRYPOINT ["code-server"]
32+
ENV LC_ALL=en_US.UTF-8
33+
34+
RUN adduser --gecos '' --disabled-password coder && \
35+
echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd
36+
37+
USER coder
38+
# We create first instead of just using WORKDIR as when WORKDIR creates, the user is root.
39+
RUN mkdir -p /home/coder/project
40+
WORKDIR /home/coder/project
41+
42+
COPY --from=0 /src/packages/server/cli-linux-x64 /usr/local/bin/code-server
43+
EXPOSE 8443
44+
45+
ENTRYPOINT ["dumb-init", "code-server"]

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
Try it out:
1111
```bash
12-
docker run -t -p 127.0.0.1:8443:8443 -v "${PWD}:/root/project" codercom/code-server code-server --allow-http --no-auth
12+
docker run -it -p 127.0.0.1:8443:8443 -v "${PWD}:/home/coder/project" codercom/code-server:1.621 --allow-http --no-auth
1313
```
1414

1515
- Code on your Chromebook, tablet, and laptop with a consistent dev environment.

build/tasks.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const libPath = path.join(__dirname, "../lib");
1212
const vscodePath = path.join(libPath, "vscode");
1313
const defaultExtensionsPath = path.join(libPath, "extensions");
1414
const pkgsPath = path.join(__dirname, "../packages");
15-
const vscodeVersion = process.env.VSCODE_VERSION || "1.32.0";
15+
const vscodeVersion = process.env.VSCODE_VERSION || "1.33.0";
1616
const vsSourceUrl = `https://codesrv-ci.cdr.sh/vstar-${vscodeVersion}.tar.gz`;
1717

1818
const buildServerBinary = register("build:server:binary", async (runner) => {

packages/ide/src/client.ts

+14-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,16 @@ export abstract class IdeClient {
4141
});
4242

4343
this.sharedProcessData = new Promise((resolve): void => {
44-
client.onSharedProcessActive(resolve);
44+
let d = client.onSharedProcessActive((data) => {
45+
d.dispose();
46+
d = client.onSharedProcessActive(() => {
47+
d.dispose();
48+
this.retry.notificationService.error(
49+
new Error("Disconnected from shared process. Searching, installing, enabling, and disabling extensions will not work until the page is refreshed."),
50+
);
51+
});
52+
resolve(data);
53+
});
4554
});
4655

4756
window.addEventListener("contextmenu", (event) => {
@@ -65,17 +74,17 @@ export abstract class IdeClient {
6574
});
6675
}
6776

68-
/**
69-
* Wrap a task in some logging, timing, and progress updates. Can optionally
70-
* wait on other tasks which won't count towards this task's time.
71-
*/
7277
public async task<T>(description: string, duration: number, task: () => Promise<T>): Promise<T>;
7378
public async task<T, V>(description: string, duration: number, task: (v: V) => Promise<T>, t: Promise<V>): Promise<T>;
7479
public async task<T, V1, V2>(description: string, duration: number, task: (v1: V1, v2: V2) => Promise<T>, t1: Promise<V1>, t2: Promise<V2>): Promise<T>;
7580
public async task<T, V1, V2, V3>(description: string, duration: number, task: (v1: V1, v2: V2, v3: V3) => Promise<T>, t1: Promise<V1>, t2: Promise<V2>, t3: Promise<V3>): Promise<T>;
7681
public async task<T, V1, V2, V3, V4>(description: string, duration: number, task: (v1: V1, v2: V2, v3: V3, v4: V4) => Promise<T>, t1: Promise<V1>, t2: Promise<V2>, t3: Promise<V3>, t4: Promise<V4>): Promise<T>;
7782
public async task<T, V1, V2, V3, V4, V5>(description: string, duration: number, task: (v1: V1, v2: V2, v3: V3, v4: V4, v5: V5) => Promise<T>, t1: Promise<V1>, t2: Promise<V2>, t3: Promise<V3>, t4: Promise<V4>, t5: Promise<V5>): Promise<T>;
7883
public async task<T, V1, V2, V3, V4, V5, V6>(description: string, duration: number, task: (v1: V1, v2: V2, v3: V3, v4: V4, v5: V5, v6: V6) => Promise<T>, t1: Promise<V1>, t2: Promise<V2>, t3: Promise<V3>, t4: Promise<V4>, t5: Promise<V5>, t6: Promise<V6>): Promise<T>;
84+
/**
85+
* Wrap a task in some logging, timing, and progress updates. Can optionally
86+
* wait on other tasks which won't count towards this task's time.
87+
*/
7988
public async task<T>(
8089
description: string, duration: number = 100, task: (...args: any[]) => Promise<T>, ...after: Array<Promise<any>> // tslint:disable-line no-any
8190
): Promise<T> {

packages/ide/src/fill/dialog.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class Dialog {
132132
public show(): void {
133133
if (!this.cachedActiveElement) {
134134
this.cachedActiveElement = document.activeElement as HTMLElement;
135-
(document.getElementById("workbench.main.container") || document.body).appendChild(this.overlay);
135+
(document.querySelector(".monaco-workbench") || document.body).appendChild(this.overlay);
136136
document.addEventListener("keydown", this.onKeydown);
137137
if (this.input) {
138138
this.input.focus();

packages/ide/src/fill/electron.ts

+4
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ const newCreateElement = <K extends keyof HTMLElementTagNameMap>(tagName: K): HT
137137
};
138138
},
139139
});
140+
view.src = require("!!file-loader?name=[path][name].[ext]!./webview.html");
141+
Object.defineProperty(view, "src", {
142+
set: (): void => { /* Nope. */ },
143+
});
140144
(view as any).getWebContents = (): void => undefined; // tslint:disable-line no-any
141145
(view as any).send = (channel: string, ...args: any[]): void => { // tslint:disable-line no-any
142146
if (args[0] && typeof args[0] === "object" && args[0].contents) {

packages/ide/src/fill/webview.html

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!DOCTYPE html>
2+
<html lang="en" style="width: 100%; height: 100%">
3+
<head>
4+
<title>Virtual Document</title>
5+
</head>
6+
<body style="margin: 0; overflow: hidden; width: 100%; height: 100%">
7+
</body>
8+
</html>

packages/ide/src/retry.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export class Retry {
147147
*
148148
* Blocking without a name will override a block with a name.
149149
*/
150-
private block(name?: string): void {
150+
public block(name?: string): void {
151151
if (!this.blocked || !name) {
152152
this.blocked = name || true;
153153
this.items.forEach((item) => {

packages/protocol/src/browser/modules/fs.ts

+5-11
Original file line numberDiff line numberDiff line change
@@ -317,17 +317,7 @@ export class FsModule {
317317
}
318318

319319
class Stats implements fs.Stats {
320-
public readonly atime: Date;
321-
public readonly mtime: Date;
322-
public readonly ctime: Date;
323-
public readonly birthtime: Date;
324-
325-
public constructor(private readonly stats: IStats) {
326-
this.atime = new Date(stats.atime);
327-
this.mtime = new Date(stats.mtime);
328-
this.ctime = new Date(stats.ctime);
329-
this.birthtime = new Date(stats.birthtime);
330-
}
320+
public constructor(private readonly stats: IStats) {}
331321

332322
public get dev(): number { return this.stats.dev; }
333323
public get ino(): number { return this.stats.ino; }
@@ -339,6 +329,10 @@ class Stats implements fs.Stats {
339329
public get size(): number { return this.stats.size; }
340330
public get blksize(): number { return this.stats.blksize; }
341331
public get blocks(): number { return this.stats.blocks; }
332+
public get atime(): Date { return this.stats.atime; }
333+
public get mtime(): Date { return this.stats.mtime; }
334+
public get ctime(): Date { return this.stats.ctime; }
335+
public get birthtime(): Date { return this.stats.birthtime; }
342336
public get atimeMs(): number { return this.stats.atimeMs; }
343337
public get mtimeMs(): number { return this.stats.mtimeMs; }
344338
public get ctimeMs(): number { return this.stats.ctimeMs; }

packages/protocol/src/browser/modules/spdlog.ts

+8
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,12 @@ export class SpdlogModule {
4545
public setAsyncMode = (bufferSize: number, flushInterval: number): Promise<void> => {
4646
return this.proxy.setAsyncMode(bufferSize, flushInterval);
4747
}
48+
49+
public createRotatingLogger(name: string, filename: string, filesize: number, filecount: number): RotatingLogger {
50+
return new RotatingLogger(this.proxy, name, filename, filesize, filecount);
51+
}
52+
53+
public createRotatingLoggerAsync(name: string, filename: string, filesize: number, filecount: number): Promise<RotatingLogger> {
54+
return Promise.resolve(this.createRotatingLogger(name, filename, filesize, filecount));
55+
}
4856
}

packages/protocol/src/common/proxy.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ export abstract class ClientProxy<T extends ServerProxy> extends EventEmitter {
5353
}
5454
}
5555

56+
/**
57+
* Remove an event listener.
58+
*/
59+
public off(event: string, cb: (...args: any[]) => void): this {
60+
// Fill it here because the fill we're using to provide EventEmitter for the
61+
// browser doesn't appear to include `off`.
62+
this.removeListener(event, cb);
63+
64+
return this;
65+
}
66+
5667
protected get proxy(): T {
5768
if (!this._proxy) {
5869
throw new Error("not initialized");
@@ -158,8 +169,10 @@ export abstract class Batch<T, A> {
158169
private readonly maxCount: number = 100,
159170
/**
160171
* Flush after not receiving more requests for this amount of time.
172+
* This is pretty low by default so essentially we just end up batching
173+
* requests that are all made at the same time.
161174
*/
162-
private readonly idleTime: number = 100,
175+
private readonly idleTime: number = 1,
163176
) {}
164177

165178
public add = (args: A): Promise<T> => {

packages/protocol/src/common/util.ts

+7
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ export const argumentToProto = (
6565
const arg = new Argument.ProxyValue();
6666
arg.setId(storeProxy(currentValue));
6767
message.setProxy(arg);
68+
} else if (currentValue instanceof Date
69+
|| (currentValue && typeof currentValue.getTime === "function")) {
70+
const arg = new Argument.DateValue();
71+
arg.setDate(currentValue.toString());
72+
message.setDate(arg);
6873
} else if (currentValue !== null && typeof currentValue === "object") {
6974
const arg = new Argument.ObjectValue();
7075
const map = arg.getDataMap();
@@ -136,6 +141,8 @@ export const protoToArgument = (
136141
}
137142

138143
return createProxy(currentMessage.getProxy()!.getId());
144+
case Argument.MsgCase.DATE:
145+
return new Date(currentMessage.getDate()!.getDate());
139146
case Argument.MsgCase.OBJECT:
140147
const obj: { [Key: string]: any } = {};
141148
currentMessage.getObject()!.getDataMap().forEach((argument, key) => {

packages/protocol/src/node/modules/fs.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ export interface Stats {
2424
mtimeMs: number;
2525
ctimeMs: number;
2626
birthtimeMs: number;
27-
atime: Date | string;
28-
mtime: Date | string;
29-
ctime: Date | string;
30-
birthtime: Date | string;
27+
atime: Date;
28+
mtime: Date;
29+
ctime: Date;
30+
birthtime: Date;
3131
_isFile: boolean;
3232
_isDirectory: boolean;
3333
_isBlockDevice: boolean;

packages/protocol/src/node/server.ts

+1
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ export class Server {
317317
logger.trace(() => [
318318
"sending reject",
319319
field("id", id) ,
320+
field("message", error.message),
320321
]);
321322

322323
const failedMessage = new Method.Fail();

packages/protocol/src/proto/node.proto

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ message Argument {
4040

4141
message UndefinedValue {}
4242

43+
message DateValue {
44+
string date = 1;
45+
}
46+
4347
oneof msg {
4448
ErrorValue error = 1;
4549
BufferValue buffer = 2;
@@ -52,6 +56,7 @@ message Argument {
5256
double number = 9;
5357
string string = 10;
5458
bool boolean = 11;
59+
DateValue date = 12;
5560
}
5661
}
5762

packages/protocol/src/proto/node_pb.d.ts

+27
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ export class Argument extends jspb.Message {
5959
getBoolean(): boolean;
6060
setBoolean(value: boolean): void;
6161

62+
hasDate(): boolean;
63+
clearDate(): void;
64+
getDate(): Argument.DateValue | undefined;
65+
setDate(value?: Argument.DateValue): void;
66+
6267
getMsgCase(): Argument.MsgCase;
6368
serializeBinary(): Uint8Array;
6469
toObject(includeInstance?: boolean): Argument.AsObject;
@@ -83,6 +88,7 @@ export namespace Argument {
8388
number: number,
8489
string: string,
8590
pb_boolean: boolean,
91+
date?: Argument.DateValue.AsObject,
8692
}
8793

8894
export class ErrorValue extends jspb.Message {
@@ -248,6 +254,26 @@ export namespace Argument {
248254
}
249255
}
250256

257+
export class DateValue extends jspb.Message {
258+
getDate(): string;
259+
setDate(value: string): void;
260+
261+
serializeBinary(): Uint8Array;
262+
toObject(includeInstance?: boolean): DateValue.AsObject;
263+
static toObject(includeInstance: boolean, msg: DateValue): DateValue.AsObject;
264+
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
265+
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
266+
static serializeBinaryToWriter(message: DateValue, writer: jspb.BinaryWriter): void;
267+
static deserializeBinary(bytes: Uint8Array): DateValue;
268+
static deserializeBinaryFromReader(message: DateValue, reader: jspb.BinaryReader): DateValue;
269+
}
270+
271+
export namespace DateValue {
272+
export type AsObject = {
273+
date: string,
274+
}
275+
}
276+
251277
export enum MsgCase {
252278
MSG_NOT_SET = 0,
253279
ERROR = 1,
@@ -261,6 +287,7 @@ export namespace Argument {
261287
NUMBER = 9,
262288
STRING = 10,
263289
BOOLEAN = 11,
290+
DATE = 12,
264291
}
265292
}
266293

0 commit comments

Comments
 (0)