Skip to content

Commit

Permalink
feature(env) add env vars CLOUDCMD_TERMINAL, CLOUDCMD_TERMINAL_PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Mar 5, 2017
1 parent ecc7da7 commit 85676cf
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 6 deletions.
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
19 changes: 18 additions & 1 deletion Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
7 changes: 7 additions & 0 deletions HELP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
10 changes: 10 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
7 changes: 4 additions & 3 deletions bin/cloudcmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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), {
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 15 additions & 0 deletions server/env.js
Original file line number Diff line number Diff line change
@@ -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];
}

0 comments on commit 85676cf

Please sign in to comment.