diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000000..6a42b9500460 --- /dev/null +++ b/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"] diff --git a/packages/runner/src/runner.ts b/packages/runner/src/runner.ts index f057aa1b0b2e..50a9c2756c8c 100644 --- a/packages/runner/src/runner.ts +++ b/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; @@ -9,7 +9,9 @@ export interface CommandResult { const execute = (command: string, args: string[] = [], options: cp.SpawnOptions, logger: Logger): Promise => { let resolve: (result: CommandResult) => void; - const prom = new Promise(res => resolve = res); + const prom = new Promise((res): void => { + resolve = res; + }); const stdout: string[] = []; const stderr: string[] = []; @@ -44,6 +46,7 @@ export type TaskFunction = (runner: Runner) => void | Promise; export interface Runner { cwd: string; + execute(command: string, args?: string[], env?: object): Promise; } @@ -90,10 +93,21 @@ export const run = (name: string = process.argv[2]): void | Promise => { cwd = path; }, execute(command: string, args: string[] = [], env?: object): Promise { - 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; }, }); diff --git a/scripts/build.sh b/scripts/build.sh index 7cb6f1c2805d..3d954fee6c97 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,5 +1,4 @@ #!/bin/bash set -e -npm install -g cross-env yarn task build:server:binary