12g 中文文档教程
12g
用于开发和 devops 的管理工具,根据 Grrr 应用的 12factor 原则
Install
$ npm install -g 12g
Commands
Display help
$ 12g -h [command] [subcommand]
Environment
Create a template .env
file
$ 12g env template
这将创建您的副本本地 .env
文件,名为 .env.template
,所有值都为空。
Get variable from a .env
file
$ 12g env get -e [target environment name] --var=DB_HOST
这将从目标上的 .env
文件中设置的环境变量中打印值。 如果未设置变量,将返回 undefined
。
List variables from a .env
file
$ 12g env list -e [target environment name]
这将列出目标上 .env
文件中的变量,不带引号或注释。 目标环境可能是 development
, staging
, production
等, 取决于您的设置。
如果目标环境是远程的,将尝试 SSH 连接, 如果可以找到 Capistrano 配置。
Json
默认值将被漂亮地打印出来,但也可以在 JSON 中列出:
$ 12g env list -e [target environment name] -o json
-o
或 --output
设置输出格式。
Current environment
$ 12g env name
这将打印出当前环境的名称。
Docker shortcut
使用 12g dock [command]
直接在您的 Docker Compose 网络服务器上执行 Docker 命令。 它必须运行,并且必须遵守我们在 @grrr-amsterdam,这基本上是将您的 httpd 服务称为“web”。
示例:
$ 12g dock bash
$ 12g dock g spawn
$ 12g dock g snippet create
Shorthand
您可以在为常见环境名称提供的参数中使用简写语法:
p
becomesproduction
s
becomesstaging
i
becomesintegration
d
becomesdevelopment
t
becomestesting
例如:
$ 12g env list -e s
列出staging
的环境。
12g
Administration tool for development and devops, according to the 12factor principles as applied by Grrr
Install
$ npm install -g 12g
Commands
Display help
$ 12g -h [command] [subcommand]
Environment
Create a template .env
file
$ 12g env template
This will create a copy of your local .env
file, named .env.template
, with all values emptied.
Get variable from a .env
file
$ 12g env get -e [target environment name] --var=DB_HOST
This will print the value from the environment variable set in the .env
file on the target. Will return undefined
if the variable is not set.
List variables from a .env
file
$ 12g env list -e [target environment name]
This will list the variables from the .env
file on the target, without quotes or comments. Target environment is probably development
, staging
, production
, etcetera, depending on your setup.
If the targeted environment is remote, an SSH connection will be attempted, if Capistrano configuration can be found.
Json
Default the values will be pretty-printed, but listing in JSON is also possible:
$ 12g env list -e [target environment name] -o json
-o
or --output
sets the output format.
Current environment
$ 12g env name
This will print out the name of the current environment.
Docker shortcut
Use 12g dock [command]
to execute a Docker command directly on your Docker Compose webserver. It has to be running and it will have to adhere to the naming standards as we use them at @grrr-amsterdam, which is basically calling your httpd service 'web'.
Examples:
$ 12g dock bash
$ 12g dock g spawn
$ 12g dock g snippet create
Shorthand
You can use shorthand syntax in the provided argument for common environment names:
p
becomesproduction
s
becomesstaging
i
becomesintegration
d
becomesdevelopment
t
becomestesting
For instance:
$ 12g env list -e s
To list the environment for staging
.