fix
This commit is contained in:
parent
35e2b8d0c9
commit
94739a8a12
@ -50,7 +50,6 @@ HTTP body 必须是 JSON object。`http_protocol` 会使用 `json:decode/1` 解
|
|||||||
"container_name": "my_nginx",
|
"container_name": "my_nginx",
|
||||||
"command": ["nginx", "-g", "daemon off;"],
|
"command": ["nginx", "-g", "daemon off;"],
|
||||||
"restart": "always",
|
"restart": "always",
|
||||||
"container_dir": "/data/apps/my_nginx",
|
|
||||||
"entrypoint": ["/docker-entrypoint.sh"],
|
"entrypoint": ["/docker-entrypoint.sh"],
|
||||||
"envs": ["ENV=prod", "TZ=Asia/Shanghai"],
|
"envs": ["ENV=prod", "TZ=Asia/Shanghai"],
|
||||||
"expose": ["80", "443/tcp", "53/udp"],
|
"expose": ["80", "443/tcp", "53/udp"],
|
||||||
@ -115,7 +114,6 @@ HTTP body 必须是 JSON object。`http_protocol` 会使用 `json:decode/1` 解
|
|||||||
|
|
||||||
| 字段 | JSON 类型 | 默认值 | 说明 |
|
| 字段 | JSON 类型 | 默认值 | 说明 |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| `container_dir` | string | `""` | 容器工作目录在 efka 主机上的应用目录,传给 efka 部署逻辑。 |
|
|
||||||
| `entrypoint` | string[] | `[]` | Docker create config 的 `entrypoint`。 |
|
| `entrypoint` | string[] | `[]` | Docker create config 的 `entrypoint`。 |
|
||||||
| `envs` | string[] | `[]` | 环境变量列表,例如 `["A=1"]`,对应 Docker create config 的 `env`。 |
|
| `envs` | string[] | `[]` | 环境变量列表,例如 `["A=1"]`,对应 Docker create config 的 `env`。 |
|
||||||
| `expose` | string[] | `[]` | 容器暴露端口,只表示容器端口,不支持宿主机端口绑定。 |
|
| `expose` | string[] | `[]` | 容器暴露端口,只表示容器端口,不支持宿主机端口绑定。 |
|
||||||
@ -145,8 +143,9 @@ HTTP body 必须是 JSON object。`http_protocol` 会使用 `json:decode/1` 解
|
|||||||
| 字段 | 当前行为 | 说明 |
|
| 字段 | 当前行为 | 说明 |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `ports` | 明确拒绝 | 如果传入会返回 `unsupported container config keys: ports`。当前只支持 `expose`,不支持宿主机端口绑定。 |
|
| `ports` | 明确拒绝 | 如果传入会返回 `unsupported container config keys: ports`。当前只支持 `expose`,不支持宿主机端口绑定。 |
|
||||||
|
| `container_dir` | 明确拒绝 | 容器目录由 efka 按系统默认规则管理,HTTP 调用方不能指定 efka 主机上的部署目录。 |
|
||||||
| `env_file` | 忽略 | 当前校验不会识别该字段,后续构造 Docker create options 时也不会使用。 |
|
| `env_file` | 忽略 | 当前校验不会识别该字段,后续构造 Docker create options 时也不会使用。 |
|
||||||
| 其他未知字段 | 忽略 | 除 `ports` 外,未知字段不会报错,也不会进入内部部署参数。 |
|
| 其他未知字段 | 忽略 | 除 `ports` 和 `container_dir` 外,未知字段不会报错,也不会进入内部部署参数。 |
|
||||||
|
|
||||||
## 5. 校验规则
|
## 5. 校验规则
|
||||||
|
|
||||||
@ -160,7 +159,7 @@ HTTP body 必须是 JSON object。`http_protocol` 会使用 `json:decode/1` 解
|
|||||||
|
|
||||||
第二层在 `docker_container_builder:deploy_request/2`:
|
第二层在 `docker_container_builder:deploy_request/2`:
|
||||||
|
|
||||||
- 先拒绝不支持的 `ports` 字段。
|
- 先拒绝不支持的 `ports` 和 `container_dir` 字段。
|
||||||
- 检查必填字段是否存在。
|
- 检查必填字段是否存在。
|
||||||
- 检查已知字段类型。
|
- 检查已知字段类型。
|
||||||
- 构造内部部署 map。
|
- 构造内部部署 map。
|
||||||
@ -191,7 +190,6 @@ miss requied parameter: <<"image">>
|
|||||||
task_id => TaskId,
|
task_id => TaskId,
|
||||||
params => #{
|
params => #{
|
||||||
container_name => ContainerName,
|
container_name => ContainerName,
|
||||||
container_dir => ContainerDir,
|
|
||||||
create => #{
|
create => #{
|
||||||
config => ContainerConfig,
|
config => ContainerConfig,
|
||||||
host_config => HostConfig,
|
host_config => HostConfig,
|
||||||
@ -564,7 +562,6 @@ nano_cpus => 1500000000
|
|||||||
task_id => 1001,
|
task_id => 1001,
|
||||||
params => #{
|
params => #{
|
||||||
container_name => <<"my_nginx">>,
|
container_name => <<"my_nginx">>,
|
||||||
container_dir => <<>>,
|
|
||||||
create => #{
|
create => #{
|
||||||
config => #{
|
config => #{
|
||||||
image => <<"docker.io/library/nginx:latest">>,
|
image => <<"docker.io/library/nginx:latest">>,
|
||||||
|
|||||||
@ -68,7 +68,7 @@ container_ref(ContainerName) when is_binary(ContainerName) ->
|
|||||||
|
|
||||||
-spec ensure_supported_deploy_config(map()) -> ok.
|
-spec ensure_supported_deploy_config(map()) -> ok.
|
||||||
ensure_supported_deploy_config(Config) when is_map(Config) ->
|
ensure_supported_deploy_config(Config) when is_map(Config) ->
|
||||||
UnsupportedKeys = [Key || Key <- [<<"ports">>], maps:is_key(Key, Config)],
|
UnsupportedKeys = [Key || Key <- [<<"ports">>, <<"container_dir">>], maps:is_key(Key, Config)],
|
||||||
case UnsupportedKeys of
|
case UnsupportedKeys of
|
||||||
[] ->
|
[] ->
|
||||||
ok;
|
ok;
|
||||||
@ -97,7 +97,6 @@ validate_deploy_config(Config) when is_map(Config) ->
|
|||||||
{<<"user">>, binary},
|
{<<"user">>, binary},
|
||||||
{<<"working_dir">>, binary},
|
{<<"working_dir">>, binary},
|
||||||
{<<"hostname">>, binary},
|
{<<"hostname">>, binary},
|
||||||
{<<"container_dir">>, binary},
|
|
||||||
{<<"network_mode">>, binary},
|
{<<"network_mode">>, binary},
|
||||||
{<<"cap_add">>, {list, binary}},
|
{<<"cap_add">>, {list, binary}},
|
||||||
{<<"cap_drop">>, {list, binary}},
|
{<<"cap_drop">>, {list, binary}},
|
||||||
@ -210,7 +209,6 @@ check_type(_, _) ->
|
|||||||
build_container_deploy_params(Config) when is_map(Config) ->
|
build_container_deploy_params(Config) when is_map(Config) ->
|
||||||
#{
|
#{
|
||||||
container_name => maps:get(<<"container_name">>, Config),
|
container_name => maps:get(<<"container_name">>, Config),
|
||||||
container_dir => maps:get(<<"container_dir">>, Config, <<>>),
|
|
||||||
create => build_docker_create_options(Config)
|
create => build_docker_create_options(Config)
|
||||||
}.
|
}.
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user