Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0c442f2

Browse files
author
Zoltan
committedMar 7, 2019
merge back codercom
2 parents 7e44a39 + 14f1230 commit 0c442f2

File tree

7 files changed

+58
-31
lines changed

7 files changed

+58
-31
lines changed
 

‎.github/CODEOWNERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
* @coderasher @kylecarbs
1+
* @coderasher @kylecarbs
2+
Dockerfile @nhooyr

‎Dockerfile

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
11
FROM node:8.9.3
22

33
# 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
4+
RUN apt-get update && apt-get install -y \
5+
libxkbfile-dev \
6+
libsecret-1-dev
67

78
# Ensure latest yarn.
8-
RUN npm install -g yarn
9-
# In the future, we can use https://github.com/yarnpkg/rfcs/pull/53 to make it use the node_modules
10-
# directly which should be faster.
9+
RUN npm install -g yarn@1.13
10+
1111
WORKDIR /src
1212
COPY . .
13-
RUN yarn --frozen-lockfile
14-
15-
RUN yarn task vscode:install
16-
RUN yarn task build:copy-vscode
17-
RUN yarn task build:web
18-
RUN yarn task build:bootstrap-fork
19-
RUN yarn task build:default-extensions
20-
2113

22-
RUN yarn task build:server:bundle
23-
RUN yarn task build:app:browser
24-
RUN yarn task build:server:binary:package
14+
# In the future, we can use https://github.com/yarnpkg/rfcs/pull/53 to make yarn use the node_modules
15+
# 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
2517

2618
# We deploy with ubuntu so that devs have a familiar environemnt.
2719
FROM ubuntu:18.10
28-
RUN apt-get update
29-
RUN apt-get install -y openssl
30-
RUN apt-get install -y net-tools
3120
WORKDIR /root/project
3221
COPY --from=0 /src/packages/server/cli-linux-x64 /usr/local/bin/code-server
3322
EXPOSE 8443
23+
RUN apt-get update && apt-get install -y \
24+
openssl \
25+
net-tools
26+
RUN apt-get install -y locales && \
27+
locale-gen en_US.UTF-8
28+
# We unfortunately cannot use update-locale because docker will not use the env variables
29+
# configured in /etc/default/locale so we need to set it manually.
30+
ENV LANG=en_US.UTF-8
3431
# Unfortunately `.` does not work with code-server.
3532
CMD code-server $PWD

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

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

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

‎packages/server/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
2626
"@types/express": "^4.16.0",
2727
"@types/fs-extra": "^5.0.4",
2828
"@types/mime-types": "^2.1.0",
29+
"@types/opn": "^5.1.0",
2930
"@types/pem": "^1.9.4",
3031
"@types/ws": "^6.0.1",
3132
"fs-extra": "^7.0.1",
3233
"nexe": "^2.0.0-rc.34",
34+
"opn": "^5.4.0",
3335
"string-replace-webpack-plugin": "^0.1.3",
3436
"ts-node": "^7.0.1",
3537
"tsconfig-paths": "^3.7.0",

‎packages/server/src/cli.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { SharedProcess, SharedProcessState } from "./vscode/sharedProcess";
1313
import { setup as setupNativeModules } from "./modules";
1414
import { fillFs } from "./fill";
1515
import { isCli, serveStatic, buildDir } from "./constants";
16+
import opn = require("opn");
1617

1718
export class Entry extends Command {
1819
public static description = "Start your own self-hosted browser-accessible VS Code";
@@ -48,11 +49,11 @@ export class Entry extends Command {
4849
}
4950

5051
const { args, flags } = this.parse(Entry);
51-
const dataDir = flags["data-dir"] || path.join(os.homedir(), ".code-server");
52-
const workingDir = args["workdir"];
52+
const dataDir = path.resolve(flags["data-dir"] || path.join(os.homedir(), ".code-server"));
53+
const workingDir = path.resolve(args["workdir"]);
5354

5455
setupNativeModules(dataDir);
55-
const builtInExtensionsDir = path.join(buildDir || path.join(__dirname, ".."), "build/extensions");
56+
const builtInExtensionsDir = path.resolve(buildDir || path.join(__dirname, ".."), "build/extensions");
5657
if (flags["bootstrap-fork"]) {
5758
const modulePath = flags["bootstrap-fork"];
5859
if (!modulePath) {
@@ -83,8 +84,8 @@ export class Entry extends Command {
8384
const logDir = path.join(dataDir, "logs", new Date().toISOString().replace(/[-:.TZ]/g, ""));
8485
process.env.VSCODE_LOGS = logDir;
8586

86-
const certPath = flags.cert;
87-
const certKeyPath = flags["cert-key"];
87+
const certPath = flags.cert ? path.resolve(flags.cert) : undefined;
88+
const certKeyPath = flags["cert-key"] ? path.resolve(flags["cert-key"]) : undefined;
8889

8990
if (certPath && !certKeyPath) {
9091
logger.error("'--cert-key' flag is required when specifying a certificate!");
@@ -134,9 +135,9 @@ export class Entry extends Command {
134135
}
135136
});
136137

137-
let password = flags["password"];
138+
let password = flags.password;
138139
if (!password) {
139-
// Generate a random password
140+
// Generate a random password with a length of 24.
140141
const buffer = Buffer.alloc(12);
141142
randomFillSync(buffer);
142143
password = buffer.toString("hex");
@@ -157,7 +158,7 @@ export class Entry extends Command {
157158
// If we're not running from the binary and we aren't serving the static
158159
// pre-built version, use webpack to serve the web files.
159160
if (!isCli && !serveStatic) {
160-
const webpackConfig = require(path.join(__dirname, "..", "..", "web", "webpack.config.js"));
161+
const webpackConfig = require(path.resolve(__dirname, "..", "..", "web", "webpack.config.js"));
161162
const compiler = require("webpack")(webpackConfig);
162163
app.use(require("webpack-dev-middleware")(compiler, {
163164
logger,
@@ -220,10 +221,20 @@ export class Entry extends Command {
220221
} else {
221222
logger.warn("Launched without authentication.");
222223
}
224+
225+
const url = `http://localhost:${flags.port}/`;
223226
logger.info(" ");
224227
logger.info("Started (click the link below to open):");
225-
logger.info(`http://localhost:${flags.port}/`);
228+
logger.info(url);
226229
logger.info(" ");
230+
231+
if (flags["open"]) {
232+
try {
233+
await opn(url);
234+
} catch (e) {
235+
logger.warn("Url couldn't be opened automatically.", field("url", url), field("exception", e));
236+
}
237+
}
227238
}
228239
}
229240

‎packages/server/src/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as path from "path";
2+
13
export const isCli = typeof process.env.CLI !== "undefined" && process.env.CLI !== "false";
24
export const serveStatic = typeof process.env.SERVE_STATIC !== "undefined" && process.env.SERVE_STATIC !== "false";
3-
export const buildDir = process.env.BUILD_DIR;
5+
export const buildDir = process.env.BUILD_DIR ? path.resolve(process.env.BUILD_DIR) : "";

‎packages/server/yarn.lock

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@
128128
resolved "https://registry.yarnpkg.com/@types/node/-/node-11.10.5.tgz#fbaca34086bdc118011e1f05c47688d432f2d571"
129129
integrity sha512-DuIRlQbX4K+d5I+GMnv+UfnGh+ist0RdlvOp+JZ7ePJ6KQONCFQv/gKYSU1ZzbVdFSUCKZOltjmpFAGGv5MdYA==
130130

131+
"@types/opn@^5.1.0":
132+
version "5.1.0"
133+
resolved "https://registry.yarnpkg.com/@types/opn/-/opn-5.1.0.tgz#bff7bc371677f4bdbb37884400e03fd81f743927"
134+
integrity sha512-TNPrB7Y1xl06zDI0aGyqkgxjhIev3oJ+cdqlZ52MTAHauWpEL/gIUdHebIfRHFZk9IqSBpE2ci1DT48iZH81yg==
135+
dependencies:
136+
"@types/node" "*"
137+
131138
"@types/pem@^1.9.4":
132139
version "1.9.5"
133140
resolved "https://registry.yarnpkg.com/@types/pem/-/pem-1.9.5.tgz#cd5548b5e0acb4b41a9e21067e9fcd8c57089c99"
@@ -2654,6 +2661,13 @@ onetime@^2.0.0:
26542661
dependencies:
26552662
mimic-fn "^1.0.0"
26562663

2664+
opn@^5.4.0:
2665+
version "5.4.0"
2666+
resolved "https://registry.yarnpkg.com/opn/-/opn-5.4.0.tgz#cb545e7aab78562beb11aa3bfabc7042e1761035"
2667+
integrity sha512-YF9MNdVy/0qvJvDtunAOzFw9iasOQHpVthTCvGzxt61Il64AYSGdK+rYwld7NAfk9qJ7dt+hymBNSc9LNYS+Sw==
2668+
dependencies:
2669+
is-wsl "^1.1.0"
2670+
26572671
optionator@^0.8.1:
26582672
version "0.8.2"
26592673
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64"

0 commit comments

Comments
 (0)
Please sign in to comment.