Skip to content

Commit 85676cf

Browse files
committed
feature(env) add env vars CLOUDCMD_TERMINAL, CLOUDCMD_TERMINAL_PATH
1 parent ecc7da7 commit 85676cf

File tree

7 files changed

+62
-6
lines changed

7 files changed

+62
-6
lines changed

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ RUN mkdir -p /usr/src/app
55
WORKDIR /usr/src/app
66

77
COPY package.json /usr/src/app/
8-
RUN npm install --production
8+
9+
RUN npm install --production && \
10+
npm i gritty
11+
912
COPY . /usr/src/app
1013

14+
ENV cloudcmd_terminal true
15+
ENV cloudcmd_terminal_path gritty
16+
1117
EXPOSE 8000
1218

1319
ENTRYPOINT ["bin/cloudcmd.js"]

Dockerfile.alpine

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,26 @@ RUN mkdir -p /usr/src/app
55
WORKDIR /usr/src/app
66

77
COPY package.json /usr/src/app/
8-
RUN npm install --production
8+
9+
RUN npm install --production && \
10+
apk add --no-cache git bash make g++ python && \
11+
npm i node-pty@">0.6.2" || \
12+
(cd node_modules && \
13+
git clone https://github.com/Tyriar/node-pty && \
14+
cd node-pty && \
15+
npm i && npm run tsc && \
16+
npm run install && \
17+
rm -rf .git && \
18+
cd ../..) && \
19+
npm i gritty && \
20+
apk del git make g++ python && \
21+
rm -rf /usr/include /tmp/* /var/cache/apk/*
22+
923
COPY . /usr/src/app
1024

25+
ENV cloudcmd_terminal true
26+
ENV cloudcmd_terminal_path gritty
27+
1128
EXPOSE 8000
1229

1330
ENTRYPOINT ["bin/cloudcmd.js"]

HELP.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,13 @@ Here is description of options:
322322
}
323323
```
324324

325+
### Environment Variables
326+
327+
Some config options can be overriden with `environment variables` such:
328+
329+
- `CLOUDCMD_TERMINAL` - enable terminal
330+
- `CLOUDCMD_TERMINAL_PATH` - set terminal path
331+
325332
Menu
326333
---------------
327334
![Menu](/img/screen/menu.png "Menu")

app.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616
"description": "Keep false to install devDependencies and build frontend",
1717
"value": "false",
1818
"required": false
19+
},
20+
"CLOUDCMD_TERMINAL": {
21+
"description": "enable terminal",
22+
"value": "true",
23+
"required": false
24+
},
25+
"CLOUDCMD_TERMINAL_PATH": {
26+
"description": "set terminal path",
27+
"value": "gritty",
28+
"required": false
1929
}
2030
}
2131
}

bin/cloudcmd.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const DIR_SERVER = '../server/';
77

88
const exit = require(DIR_SERVER + 'exit');
99
const config = require(DIR_SERVER + 'config');
10+
const env = require(DIR_SERVER + 'env');
1011

1112
const argv = process.argv;
1213
const args = require('minimist')(argv.slice(2), {
@@ -51,9 +52,9 @@ const args = require('minimist')(argv.slice(2), {
5152
prefix : config('prefix') || '',
5253
progress : config('progress'),
5354
console : config('console'),
54-
terminal : config('terminal'),
55+
terminal : env.bool('terminal') || config('terminal'),
5556

56-
'terminal-path': config('terminalPath'),
57+
'terminal-path': env('terminal_path') || config('terminalPath'),
5758
'config-dialog': config('configDialog'),
5859
'one-panel-mode': config('onePanelMode'),
5960
'html-dialogs': config('htmlDialogs')
@@ -93,7 +94,7 @@ if (args.version) {
9394
config('progress', args.progress);
9495
config('console', args.console);
9596
config('terminal', args.terminal);
96-
config('terminalPath', args.terminalPath);
97+
config('terminalPath', args['terminal-path']);
9798
config('editor', args.editor);
9899
config('prefix', args.prefix);
99100
config('root', args.root);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"legacy:help": "cp json/help.json legacy/json/",
9898
"rm:server": "rimraf server_ legacy",
9999
"rm:client": "rimraf dist dist-dev",
100-
"heroku-postbuild": "redrun 6to5:client -- --progress"
100+
"heroku-postbuild": "redrun 6to5:client -- --progress && npm i gritty"
101101
},
102102
"directories": {
103103
"man": "man"

server/env.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
const env = process.env;
4+
const up = (a) => a.toUpperCase();
5+
6+
module.exports = parse;
7+
module.exports.bool = (name) => Boolean(parse(name));
8+
9+
function parse(name) {
10+
const small = `cloudcmd_${name}`;
11+
const big = up(small);
12+
13+
return env[small] || env[big];
14+
}
15+

0 commit comments

Comments
 (0)