Skip to content

Commit

Permalink
Add Dockerfile and some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nhooyr committed Mar 6, 2019
1 parent 3fbdb2e commit 3ff2967
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
30 changes: 30 additions & 0 deletions Dockerfile
@@ -0,0 +1,30 @@
FROM node:8.15.0

# Install VS Code's deps. These are the only two it seems we need.
RUN apt-get update
RUN apt-get install -y libxkbfile-dev libsecret-1-dev

# Ensure latest yarn.
RUN npm install -g yarn

# Cache deps as much as we can.
# In the future, we can use https://github.com/yarnpkg/rfcs/pull/53 to make it use node_modules
# directly which should be faster.
WORKDIR /src
COPY package.json .
COPY yarn.lock .
COPY tsconfig.json .
COPY packages packages
COPY rules rules
COPY scripts scripts
RUN yarn

COPY . .
RUN yarn task build:server:binary

# We deploy with ubuntu so that devs have a familiar environemnt.
FROM ubuntu
WORKDIR /root
COPY --from=0 /src/packages/server/cli-linux /usr/local/bin/code-server
EXPOSE 8443
CMD ["code-server"]
20 changes: 17 additions & 3 deletions packages/runner/src/runner.ts
@@ -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 @@ -44,6 +46,7 @@ export type TaskFunction = (runner: Runner) => void | Promise<void>;

export interface Runner {
cwd: string;

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

Expand Down Expand Up @@ -90,10 +93,21 @@ 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);
prom.then((result: CommandResult) => {
if (result.exitCode != 0) {
log.error("failed",
field("exitCode", result.exitCode),
field("stdout", result.stdout),
field("stderr", result.stderr)
);
}
});

return prom;
},
});

Expand Down
1 change: 0 additions & 1 deletion scripts/build.sh
@@ -1,5 +1,4 @@
#!/bin/bash
set -e

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

0 comments on commit 3ff2967

Please sign in to comment.