zrb 0.0.45__py3-none-any.whl → 0.0.47__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zrb/__init__.py +1 -1
- zrb/action/runner.py +2 -3
- zrb/builtin/__init__.py +2 -0
- zrb/builtin/_group.py +1 -1
- zrb/builtin/env.py +0 -2
- zrb/builtin/generator/_common.py +15 -16
- zrb/builtin/generator/docker_compose_task/template/src/kebab-task-name/docker-compose.yml +7 -1
- zrb/builtin/generator/docker_compose_task/template/src/kebab-task-name/image/Dockerfile +3 -1
- zrb/builtin/generator/docker_compose_task/template/src/kebab-task-name/image/main.py +0 -5
- zrb/builtin/generator/fastapp/add.py +3 -3
- zrb/builtin/generator/fastapp/template/_automate/snake_app_name/_common.py +17 -7
- zrb/builtin/generator/fastapp/template/_automate/snake_app_name/config/docker-compose.env +3 -0
- zrb/builtin/generator/fastapp/template/_automate/snake_app_name/container.py +14 -5
- zrb/builtin/generator/fastapp/template/_automate/snake_app_name/image.py +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_app_name/local.py +1 -2
- zrb/builtin/generator/fastapp/template/src/kebab-app-name/docker-compose.yml +24 -6
- zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/Dockerfile +3 -1
- zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/template.env +1 -1
- zrb/builtin/generator/fastapp_module/add.py +266 -83
- zrb/builtin/generator/project/template/README.md +19 -3
- zrb/builtin/generator/project_task/add.py +12 -13
- zrb/builtin/generator/project_task/task_factory.py +12 -14
- zrb/builtin/generator/simple_python_app/add.py +3 -3
- zrb/builtin/generator/simple_python_app/template/src/kebab-app-name/docker-compose.yml +7 -1
- zrb/builtin/generator/simple_python_app/template/src/kebab-app-name/src/Dockerfile +3 -1
- zrb/builtin/generator/simple_python_app/template/src/kebab-app-name/src/main.py +0 -5
- zrb/builtin/md5.py +5 -4
- zrb/builtin/project.py +32 -0
- zrb/helper/docker_compose/file.py +22 -0
- zrb/helper/env_map/fetch.py +68 -0
- zrb/helper/file/copy_tree.py +6 -7
- zrb/helper/file/text.py +20 -0
- zrb/helper/string/jinja.py +11 -0
- zrb/task/base_task.py +457 -4
- zrb/task/cmd_task.py +1 -2
- zrb/task/decorator.py +1 -1
- zrb/task/docker_compose_task.py +3 -4
- zrb/task/http_checker.py +1 -2
- zrb/task/installer/factory.py +6 -4
- zrb/task/path_checker.py +3 -4
- zrb/task/port_checker.py +1 -2
- zrb/task/resource_maker.py +2 -3
- zrb/task_env/env.py +4 -3
- {zrb-0.0.45.dist-info → zrb-0.0.47.dist-info}/METADATA +3 -1
- {zrb-0.0.45.dist-info → zrb-0.0.47.dist-info}/RECORD +52 -51
- zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/module_disabled.env +0 -0
- zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/module_enabled.env +0 -0
- zrb/helper/dockercompose/read.py +0 -9
- zrb/task/base_model.py +0 -456
- zrb/task_group/group.py +0 -36
- /zrb/builtin/generator/fastapp/template/{_automate/snake_app_name/config/module_disabled.env → src/kebab-app-name/all-module-disabled.env} +0 -0
- /zrb/builtin/generator/fastapp/template/{_automate/snake_app_name/config/module_enabled.env → src/kebab-app-name/all-module-enabled.env} +0 -0
- /zrb/helper/{dockercompose → docker_compose}/fetch_external_env.py +0 -0
- /zrb/{task_group → helper/env_map}/__init__.py +0 -0
- {zrb-0.0.45.dist-info → zrb-0.0.47.dist-info}/LICENSE +0 -0
- {zrb-0.0.45.dist-info → zrb-0.0.47.dist-info}/WHEEL +0 -0
- {zrb-0.0.45.dist-info → zrb-0.0.47.dist-info}/entry_points.txt +0 -0
zrb/__init__.py
CHANGED
@@ -17,7 +17,7 @@ from .task_input.password_input import PasswordInput
|
|
17
17
|
from .task_input.str_input import StrInput
|
18
18
|
from .task_env.env import Env
|
19
19
|
from .task_env.env_file import EnvFile
|
20
|
-
from .
|
20
|
+
from .task.base_task import Group
|
21
21
|
from .builtin import _group as builtin_group
|
22
22
|
from .helper.default_env import inject_default_env
|
23
23
|
|
zrb/action/runner.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
from typing import List, Mapping, Union
|
2
2
|
from ..action.base_action import BaseAction
|
3
|
-
from ..task.base_task import BaseTask
|
4
|
-
from ..task_group.group import Group as TaskGroup
|
3
|
+
from ..task.base_task import BaseTask, Group as TaskGroup
|
5
4
|
import click
|
6
5
|
|
7
6
|
CliSubcommand = Union[click.Group, click.Command]
|
@@ -70,7 +69,7 @@ class Runner(BaseAction):
|
|
70
69
|
task_cmd_name = task.get_cmd_name()
|
71
70
|
task_description = task.get_description()
|
72
71
|
task_main_loop = task.create_main_loop(
|
73
|
-
env_prefix=self.env_prefix, raise_error=
|
72
|
+
env_prefix=self.env_prefix, raise_error=True
|
74
73
|
)
|
75
74
|
command = click.Command(
|
76
75
|
callback=task_main_loop, name=task_cmd_name, help=task_description
|
zrb/builtin/__init__.py
CHANGED
@@ -3,6 +3,7 @@ from . import env
|
|
3
3
|
from . import eval
|
4
4
|
from . import md5
|
5
5
|
from . import principle
|
6
|
+
from . import project
|
6
7
|
from . import ubuntu
|
7
8
|
from . import update
|
8
9
|
from . import version
|
@@ -20,6 +21,7 @@ assert env
|
|
20
21
|
assert eval
|
21
22
|
assert md5
|
22
23
|
assert principle
|
24
|
+
assert project
|
23
25
|
assert ubuntu
|
24
26
|
assert update
|
25
27
|
assert version
|
zrb/builtin/_group.py
CHANGED
zrb/builtin/env.py
CHANGED
zrb/builtin/generator/_common.py
CHANGED
@@ -10,11 +10,12 @@ from ...task_input.int_input import IntInput
|
|
10
10
|
from ...helper.accessories.name import get_random_name
|
11
11
|
from ...helper.codemod.add_assert_resource import add_assert_resource
|
12
12
|
from ...helper.codemod.add_import_module import add_import_module
|
13
|
-
from ...helper import util
|
14
13
|
from ...helper.middlewares.replacement import (
|
15
14
|
add_pascal_key, add_snake_key, add_camel_key,
|
16
15
|
add_kebab_key, add_human_readable_key
|
17
16
|
)
|
17
|
+
from ...helper.file.text import read_text_file_async, write_text_file_async
|
18
|
+
from ...helper import util
|
18
19
|
import os
|
19
20
|
|
20
21
|
|
@@ -130,7 +131,7 @@ def create_register_task_module(
|
|
130
131
|
validate_project_dir(project_dir)
|
131
132
|
task_name = kwargs.get('task_name')
|
132
133
|
task.print_out(f'Register module: _automate.{task_name}')
|
133
|
-
register_module(
|
134
|
+
await register_module(
|
134
135
|
project_dir=project_dir,
|
135
136
|
module_name='.'.join([
|
136
137
|
'_automate', util.to_snake_case(task_name)
|
@@ -179,7 +180,7 @@ def _create_register_app_module(
|
|
179
180
|
app_name = kwargs.get('app_name')
|
180
181
|
task.print_out(f'Register module: _automate.{app_name}.{module}')
|
181
182
|
snake_app_name = util.to_snake_case(app_name)
|
182
|
-
register_module(
|
183
|
+
await register_module(
|
183
184
|
project_dir=project_dir,
|
184
185
|
module_name='.'.join([
|
185
186
|
'_automate', snake_app_name, module
|
@@ -189,22 +190,20 @@ def _create_register_app_module(
|
|
189
190
|
return task
|
190
191
|
|
191
192
|
|
192
|
-
def register_module(
|
193
|
+
async def register_module(
|
193
194
|
project_dir: str, module_name: str, alias: Optional[str] = None
|
194
195
|
):
|
195
196
|
zrb_init_path = os.path.join(project_dir, 'zrb_init.py')
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
code
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
with open(zrb_init_path, 'w') as f:
|
207
|
-
f.write(code)
|
197
|
+
code = await read_text_file_async(zrb_init_path)
|
198
|
+
if alias is None:
|
199
|
+
alias = module_name.split('.')[-1]
|
200
|
+
code = add_import_module(
|
201
|
+
code=code,
|
202
|
+
module_path=module_name,
|
203
|
+
alias=alias
|
204
|
+
)
|
205
|
+
code = add_assert_resource(code, alias)
|
206
|
+
await write_text_file_async(zrb_init_path, code)
|
208
207
|
return True
|
209
208
|
|
210
209
|
|
@@ -9,4 +9,10 @@ services:
|
|
9
9
|
APP_MESSAGE: '${MESSAGE:-Hello, world!}'
|
10
10
|
APP_PORT: '${CONTAINER_PORT:-8080}'
|
11
11
|
ports:
|
12
|
-
- ${HOST_PORT:-8080}:${CONTAINER_PORT:-8080}
|
12
|
+
- ${HOST_PORT:-8080}:${CONTAINER_PORT:-8080}
|
13
|
+
restart: on-failure
|
14
|
+
healthcheck:
|
15
|
+
test: ["CMD-SHELL", "curl --fail http://localhost:${APP_PORT:-8080}/ || exit 1"]
|
16
|
+
interval: 5s
|
17
|
+
timeout: 1s
|
18
|
+
retries: 30
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import uvicorn
|
2
1
|
import os
|
3
2
|
|
4
3
|
MESSAGE = os.getenv('APP_MESSAGE', 'Hello, world!')
|
@@ -19,7 +18,3 @@ async def app(scope, receive, send):
|
|
19
18
|
'type': 'http.response.body',
|
20
19
|
'body': bytes(MESSAGE, 'utf-8'),
|
21
20
|
})
|
22
|
-
|
23
|
-
|
24
|
-
if __name__ == "__main__":
|
25
|
-
uvicorn.run("main:app", host='0.0.0.0', port=PORT, log_level="info")
|
@@ -71,15 +71,15 @@ register_local_app_module = create_register_local_app_module(
|
|
71
71
|
)
|
72
72
|
|
73
73
|
register_container_app_module = create_register_container_app_module(
|
74
|
-
upstreams=[
|
74
|
+
upstreams=[register_local_app_module]
|
75
75
|
)
|
76
76
|
|
77
77
|
register_image_app_module = create_register_image_app_module(
|
78
|
-
upstreams=[
|
78
|
+
upstreams=[register_container_app_module]
|
79
79
|
)
|
80
80
|
|
81
81
|
register_deployment_app_module = create_register_deployment_app_module(
|
82
|
-
upstreams=[
|
82
|
+
upstreams=[register_image_app_module]
|
83
83
|
)
|
84
84
|
|
85
85
|
add_project_task = create_add_project_automation(
|
@@ -1,5 +1,6 @@
|
|
1
1
|
from zrb import (
|
2
|
-
BoolInput, ChoiceInput, IntInput, StrInput, Env,
|
2
|
+
BoolInput, ChoiceInput, IntInput, StrInput, Env, EnvFile,
|
3
|
+
HTTPChecker, PortChecker
|
3
4
|
)
|
4
5
|
import os
|
5
6
|
|
@@ -154,6 +155,15 @@ pulumi_stack_input = StrInput(
|
|
154
155
|
default=os.getenv('ZRB_ENV', 'dev')
|
155
156
|
)
|
156
157
|
|
158
|
+
###############################################################################
|
159
|
+
# Env file Definitions
|
160
|
+
###############################################################################
|
161
|
+
|
162
|
+
compose_env_file = EnvFile(
|
163
|
+
env_file=os.path.join(CURRENT_DIR, 'config', 'docker-compose.env'),
|
164
|
+
prefix='CONTAINER_ENV_PREFIX'
|
165
|
+
)
|
166
|
+
|
157
167
|
###############################################################################
|
158
168
|
# Env Definitions
|
159
169
|
###############################################################################
|
@@ -200,12 +210,6 @@ compose_app_broker_type_env = Env(
|
|
200
210
|
default='rabbitmq'
|
201
211
|
)
|
202
212
|
|
203
|
-
compose_app_host_port_env = Env(
|
204
|
-
name='APP_HOST_PORT',
|
205
|
-
os_name='CONTAINER_ENV_PREFIX_APP_HOST_PORT',
|
206
|
-
default='httpPort'
|
207
|
-
)
|
208
|
-
|
209
213
|
compose_rabbitmq_host_port_env = Env(
|
210
214
|
name='RABBITMQ_HOST_PORT',
|
211
215
|
os_name='CONTAINER_ENV_PREFIX_RABBITMQ_HOST_PORT',
|
@@ -272,3 +276,9 @@ start_support_container_compose_profile_env = Env(
|
|
272
276
|
'}}'
|
273
277
|
])
|
274
278
|
)
|
279
|
+
|
280
|
+
all_compose_profile_env = Env(
|
281
|
+
name='COMPOSE_PROFILES',
|
282
|
+
os_name='',
|
283
|
+
default='monolith,microservices,kafka,rabbitmq'
|
284
|
+
)
|
@@ -7,8 +7,8 @@ from ._common import (
|
|
7
7
|
kafka_plaintext_checker, pandaproxy_outside_checker,
|
8
8
|
pandaproxy_plaintext_checker,
|
9
9
|
local_input, mode_input, host_input, https_input, image_input,
|
10
|
-
|
11
|
-
start_container_compose_profile_env,
|
10
|
+
compose_env_file, compose_app_broker_type_env,
|
11
|
+
start_container_compose_profile_env, all_compose_profile_env, image_env,
|
12
12
|
compose_rabbitmq_host_port_env, compose_rabbitmq_management_host_port_env,
|
13
13
|
compose_redpanda_console_host_port_env,
|
14
14
|
compose_kafka_outside_host_port_env,
|
@@ -21,7 +21,6 @@ from .image import build_snake_app_name_image
|
|
21
21
|
compose_env_prefix = 'CONTAINER_ENV_PREFIX'
|
22
22
|
compose_envs = [
|
23
23
|
compose_app_broker_type_env,
|
24
|
-
compose_app_host_port_env,
|
25
24
|
compose_rabbitmq_host_port_env,
|
26
25
|
compose_rabbitmq_management_host_port_env,
|
27
26
|
compose_redpanda_console_host_port_env,
|
@@ -43,7 +42,11 @@ remove_snake_app_name_container = DockerComposeTask(
|
|
43
42
|
cwd=RESOURCE_DIR,
|
44
43
|
compose_cmd='down',
|
45
44
|
compose_env_prefix=compose_env_prefix,
|
46
|
-
|
45
|
+
env_files=[compose_env_file],
|
46
|
+
envs=compose_envs + [
|
47
|
+
image_env,
|
48
|
+
all_compose_profile_env
|
49
|
+
],
|
47
50
|
)
|
48
51
|
runner.register(remove_snake_app_name_container)
|
49
52
|
|
@@ -67,8 +70,10 @@ start_snake_app_name_container = DockerComposeTask(
|
|
67
70
|
cwd=RESOURCE_DIR,
|
68
71
|
compose_cmd='up',
|
69
72
|
compose_env_prefix=compose_env_prefix,
|
73
|
+
env_files=[compose_env_file],
|
70
74
|
envs=compose_envs + [
|
71
75
|
start_container_compose_profile_env,
|
76
|
+
image_env,
|
72
77
|
],
|
73
78
|
checkers=[
|
74
79
|
app_container_checker,
|
@@ -91,6 +96,10 @@ stop_snake_app_name_container = DockerComposeTask(
|
|
91
96
|
cwd=RESOURCE_DIR,
|
92
97
|
compose_cmd='stop',
|
93
98
|
compose_env_prefix=compose_env_prefix,
|
94
|
-
|
99
|
+
env_files=[compose_env_file],
|
100
|
+
envs=compose_envs + [
|
101
|
+
image_env,
|
102
|
+
all_compose_profile_env
|
103
|
+
],
|
95
104
|
)
|
96
105
|
runner.register(stop_snake_app_name_container)
|
@@ -9,7 +9,7 @@ from ._common import (
|
|
9
9
|
kafka_plaintext_checker, pandaproxy_outside_checker,
|
10
10
|
pandaproxy_plaintext_checker, app_local_checker,
|
11
11
|
local_input, mode_input, host_input, https_input, image_input,
|
12
|
-
local_app_port_env, local_app_broker_type_env,
|
12
|
+
local_app_port_env, local_app_broker_type_env,
|
13
13
|
compose_rabbitmq_host_port_env, compose_rabbitmq_management_host_port_env,
|
14
14
|
compose_redpanda_console_host_port_env,
|
15
15
|
compose_kafka_outside_host_port_env,
|
@@ -27,7 +27,6 @@ support_compose_env_prefix = 'CONTAINER_ENV_PREFIX'
|
|
27
27
|
support_compose_envs = [
|
28
28
|
local_app_broker_type_env,
|
29
29
|
local_app_port_env,
|
30
|
-
compose_app_host_port_env,
|
31
30
|
compose_rabbitmq_host_port_env,
|
32
31
|
compose_rabbitmq_management_host_port_env,
|
33
32
|
compose_redpanda_console_host_port_env,
|
@@ -68,22 +68,30 @@ services:
|
|
68
68
|
retries: 30
|
69
69
|
|
70
70
|
|
71
|
-
kebab-app-name
|
71
|
+
kebab-app-name:
|
72
72
|
build:
|
73
73
|
dockerfile: Dockerfile
|
74
74
|
context: ./src
|
75
75
|
image: ${IMAGE:-kebab-app-name}
|
76
76
|
container_name: snake_app_name
|
77
77
|
hostname: snake_app_name
|
78
|
-
env_file:
|
78
|
+
env_file:
|
79
|
+
- 'src/template.env'
|
79
80
|
environment:
|
80
81
|
APP_NAME: ${APP_NAME:-kebab-app-name}
|
81
82
|
APP_PORT: ${APP_PORT:-8080}
|
83
|
+
APP_RMQ_CONNECTION: ${APP_CONTAINER_RMQ_CONNECTION:-amqp://guest:guest@rabbitmq/}
|
84
|
+
APP_KAFKA_BOOTSTRAP_SERVERS: ${APP_CONTAINER_KAFKA_BOOTSTRAP_SERVERS:-redpanda:9092}
|
82
85
|
ports:
|
83
86
|
- "${APP_HOST_PORT:-8080}:${APP_PORT:-8080}"
|
84
87
|
restart: on-failure
|
85
88
|
profiles:
|
86
89
|
- monolith
|
90
|
+
healthcheck:
|
91
|
+
test: ["CMD-SHELL", "curl --fail http://localhost:${APP_PORT:-8080}/ || exit 1"]
|
92
|
+
interval: 5s
|
93
|
+
timeout: 1s
|
94
|
+
retries: 30
|
87
95
|
|
88
96
|
|
89
97
|
kebab-app-name-gateway:
|
@@ -95,13 +103,23 @@ services:
|
|
95
103
|
hostname: snake_app_name_gateway
|
96
104
|
env_file:
|
97
105
|
- 'src/template.env'
|
98
|
-
- '
|
106
|
+
- 'all-module-enabled.env'
|
99
107
|
environment:
|
100
108
|
APP_NAME: ${APP_NAME:-kebab-app-name}-gateway
|
101
|
-
APP_PORT: ${
|
109
|
+
APP_PORT: ${APP_GATEWAY_PORT:-8080}
|
110
|
+
APP_RMQ_CONNECTION: ${APP_CONTAINER_RMQ_CONNECTION:-amqp://guest:guest@rabbitmq/}
|
111
|
+
APP_KAFKA_BOOTSTRAP_SERVERS: ${APP_CONTAINER_KAFKA_BOOTSTRAP_SERVERS:-redpanda:9092}
|
102
112
|
APP_ENABLE_MESSAGE_CONSUMER: false
|
113
|
+
APP_ENABLE_RPC_SERVER: false
|
114
|
+
APP_ENABLE_API: true
|
115
|
+
APP_ENABLE_FRONTEND: true
|
103
116
|
ports:
|
104
|
-
- "${
|
117
|
+
- "${APP_GATEWAY_HOST_PORT:-8080}:${APP_GATEWAY_PORT:-8080}"
|
105
118
|
restart: on-failure
|
106
119
|
profiles:
|
107
|
-
- microservices
|
120
|
+
- microservices
|
121
|
+
healthcheck:
|
122
|
+
test: ["CMD-SHELL", "curl --fail http://localhost:${APP_GATEWAY_PORT:-8080}/ || exit 1"]
|
123
|
+
interval: 5s
|
124
|
+
timeout: 1s
|
125
|
+
retries: 30
|
@@ -6,9 +6,11 @@ RUN npm install && npm run build
|
|
6
6
|
|
7
7
|
# Second stage: build the API and copy the frontend build
|
8
8
|
FROM python:3.10-slim
|
9
|
+
ENV APP_HOST 0.0.0.0
|
10
|
+
ENV APP_PORT 8080
|
9
11
|
WORKDIR /home
|
10
12
|
COPY requirements.txt .
|
11
13
|
RUN pip install -r requirements.txt
|
12
14
|
COPY . .
|
13
15
|
COPY --from=frontend-builder /frontend/build /home/frontend/build
|
14
|
-
CMD
|
16
|
+
CMD uvicorn main:app --host "$APP_HOST" --port "$APP_PORT"
|