diff --git a/Dockerfile b/Dockerfile index 0364085a..ef4f0767 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,9 +5,15 @@ RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY package.json /usr/src/app/ -RUN npm install --production + +RUN npm install --production && \ + npm i gritty + COPY . /usr/src/app +ENV cloudcmd_terminal true +ENV cloudcmd_terminal_path gritty + EXPOSE 8000 ENTRYPOINT ["bin/cloudcmd.js"] diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 97e3540e..636aacf2 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -5,9 +5,26 @@ RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY package.json /usr/src/app/ -RUN npm install --production + +RUN npm install --production && \ + apk add --no-cache git bash make g++ python && \ + npm i node-pty@">0.6.2" || \ + (cd node_modules && \ + git clone https://github.com/Tyriar/node-pty && \ + cd node-pty && \ + npm i && npm run tsc && \ + npm run install && \ + rm -rf .git && \ + cd ../..) && \ + npm i gritty && \ + apk del git make g++ python && \ + rm -rf /usr/include /tmp/* /var/cache/apk/* + COPY . /usr/src/app +ENV cloudcmd_terminal true +ENV cloudcmd_terminal_path gritty + EXPOSE 8000 ENTRYPOINT ["bin/cloudcmd.js"] diff --git a/HELP.md b/HELP.md index 1f03922f..d9e818a2 100644 --- a/HELP.md +++ b/HELP.md @@ -322,6 +322,13 @@ Here is description of options: } ``` +### Environment Variables + +Some config options can be overriden with `environment variables` such: + +- `CLOUDCMD_TERMINAL` - enable terminal +- `CLOUDCMD_TERMINAL_PATH` - set terminal path + Menu --------------- ![Menu](/img/screen/menu.png "Menu") diff --git a/app.json b/app.json index 841b3bef..f184be78 100644 --- a/app.json +++ b/app.json @@ -16,6 +16,16 @@ "description": "Keep false to install devDependencies and build frontend", "value": "false", "required": false + }, + "CLOUDCMD_TERMINAL": { + "description": "enable terminal", + "value": "true", + "required": false + }, + "CLOUDCMD_TERMINAL_PATH": { + "description": "set terminal path", + "value": "gritty", + "required": false } } } diff --git a/bin/cloudcmd.js b/bin/cloudcmd.js index cfd2a6aa..c72ed946 100755 --- a/bin/cloudcmd.js +++ b/bin/cloudcmd.js @@ -7,6 +7,7 @@ const DIR_SERVER = '../server/'; const exit = require(DIR_SERVER + 'exit'); const config = require(DIR_SERVER + 'config'); +const env = require(DIR_SERVER + 'env'); const argv = process.argv; const args = require('minimist')(argv.slice(2), { @@ -51,9 +52,9 @@ const args = require('minimist')(argv.slice(2), { prefix : config('prefix') || '', progress : config('progress'), console : config('console'), - terminal : config('terminal'), + terminal : env.bool('terminal') || config('terminal'), - 'terminal-path': config('terminalPath'), + 'terminal-path': env('terminal_path') || config('terminalPath'), 'config-dialog': config('configDialog'), 'one-panel-mode': config('onePanelMode'), 'html-dialogs': config('htmlDialogs') @@ -93,7 +94,7 @@ if (args.version) { config('progress', args.progress); config('console', args.console); config('terminal', args.terminal); - config('terminalPath', args.terminalPath); + config('terminalPath', args['terminal-path']); config('editor', args.editor); config('prefix', args.prefix); config('root', args.root); diff --git a/package.json b/package.json index 453649b9..59af4985 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "legacy:help": "cp json/help.json legacy/json/", "rm:server": "rimraf server_ legacy", "rm:client": "rimraf dist dist-dev", - "heroku-postbuild": "redrun 6to5:client -- --progress" + "heroku-postbuild": "redrun 6to5:client -- --progress && npm i gritty" }, "directories": { "man": "man" diff --git a/server/env.js b/server/env.js new file mode 100644 index 00000000..7ccdcc49 --- /dev/null +++ b/server/env.js @@ -0,0 +1,15 @@ +'use strict'; + +const env = process.env; +const up = (a) => a.toUpperCase(); + +module.exports = parse; +module.exports.bool = (name) => Boolean(parse(name)); + +function parse(name) { + const small = `cloudcmd_${name}`; + const big = up(small); + + return env[small] || env[big]; +} +