zrb 0.0.46__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/action/runner.py +1 -1
- zrb/builtin/generator/_common.py +7 -8
- 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 +11 -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 +4 -2
- 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 +19 -6
- zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/template.env +1 -1
- zrb/builtin/generator/fastapp_module/add.py +259 -106
- zrb/builtin/generator/project_task/add.py +5 -6
- zrb/builtin/generator/project_task/task_factory.py +4 -6
- 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 +3 -2
- zrb/builtin/project.py +2 -60
- zrb/helper/docker_compose/file.py +22 -0
- zrb/helper/env_map/__init__.py +0 -0
- zrb/helper/env_map/fetch.py +68 -0
- zrb/helper/file/copy_tree.py +6 -7
- zrb/helper/file/text.py +12 -4
- zrb/task/base_task.py +10 -10
- zrb/task/docker_compose_task.py +2 -2
- zrb/task/installer/factory.py +6 -5
- zrb/task/path_checker.py +2 -2
- zrb/task/resource_maker.py +1 -1
- zrb/task_env/env.py +4 -3
- {zrb-0.0.46.dist-info → zrb-0.0.47.dist-info}/METADATA +1 -1
- {zrb-0.0.46.dist-info → zrb-0.0.47.dist-info}/RECORD +41 -38
- zrb/helper/dockercompose/read.py +0 -9
- /zrb/builtin/generator/fastapp/template/src/kebab-app-name/{src/module_disabled.env → all-module-disabled.env} +0 -0
- /zrb/builtin/generator/fastapp/template/src/kebab-app-name/{src/module_enabled.env → all-module-enabled.env} +0 -0
- /zrb/helper/{dockercompose → docker_compose}/fetch_external_env.py +0 -0
- {zrb-0.0.46.dist-info → zrb-0.0.47.dist-info}/LICENSE +0 -0
- {zrb-0.0.46.dist-info → zrb-0.0.47.dist-info}/WHEEL +0 -0
- {zrb-0.0.46.dist-info → zrb-0.0.47.dist-info}/entry_points.txt +0 -0
zrb/action/runner.py
CHANGED
@@ -69,7 +69,7 @@ class Runner(BaseAction):
|
|
69
69
|
task_cmd_name = task.get_cmd_name()
|
70
70
|
task_description = task.get_description()
|
71
71
|
task_main_loop = task.create_main_loop(
|
72
|
-
env_prefix=self.env_prefix, raise_error=
|
72
|
+
env_prefix=self.env_prefix, raise_error=True
|
73
73
|
)
|
74
74
|
command = click.Command(
|
75
75
|
callback=task_main_loop, name=task_cmd_name, help=task_description
|
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,12 +190,11 @@ 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
|
-
code = f.read()
|
197
|
+
code = await read_text_file_async(zrb_init_path)
|
198
198
|
if alias is None:
|
199
199
|
alias = module_name.split('.')[-1]
|
200
200
|
code = add_import_module(
|
@@ -203,8 +203,7 @@ def register_module(
|
|
203
203
|
alias=alias
|
204
204
|
)
|
205
205
|
code = add_assert_resource(code, alias)
|
206
|
-
|
207
|
-
f.write(code)
|
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',
|
@@ -7,7 +7,7 @@ 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
|
-
|
10
|
+
compose_env_file, compose_app_broker_type_env,
|
11
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,
|
@@ -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,6 +42,7 @@ remove_snake_app_name_container = DockerComposeTask(
|
|
43
42
|
cwd=RESOURCE_DIR,
|
44
43
|
compose_cmd='down',
|
45
44
|
compose_env_prefix=compose_env_prefix,
|
45
|
+
env_files=[compose_env_file],
|
46
46
|
envs=compose_envs + [
|
47
47
|
image_env,
|
48
48
|
all_compose_profile_env
|
@@ -70,6 +70,7 @@ start_snake_app_name_container = DockerComposeTask(
|
|
70
70
|
cwd=RESOURCE_DIR,
|
71
71
|
compose_cmd='up',
|
72
72
|
compose_env_prefix=compose_env_prefix,
|
73
|
+
env_files=[compose_env_file],
|
73
74
|
envs=compose_envs + [
|
74
75
|
start_container_compose_profile_env,
|
75
76
|
image_env,
|
@@ -95,6 +96,7 @@ stop_snake_app_name_container = DockerComposeTask(
|
|
95
96
|
cwd=RESOURCE_DIR,
|
96
97
|
compose_cmd='stop',
|
97
98
|
compose_env_prefix=compose_env_prefix,
|
99
|
+
env_files=[compose_env_file],
|
98
100
|
envs=compose_envs + [
|
99
101
|
image_env,
|
100
102
|
all_compose_profile_env
|
@@ -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,14 +68,15 @@ 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}
|
@@ -86,6 +87,11 @@ services:
|
|
86
87
|
restart: on-failure
|
87
88
|
profiles:
|
88
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
|
89
95
|
|
90
96
|
|
91
97
|
kebab-app-name-gateway:
|
@@ -97,16 +103,23 @@ services:
|
|
97
103
|
hostname: snake_app_name_gateway
|
98
104
|
env_file:
|
99
105
|
- 'src/template.env'
|
100
|
-
- '
|
106
|
+
- 'all-module-enabled.env'
|
101
107
|
environment:
|
102
108
|
APP_NAME: ${APP_NAME:-kebab-app-name}-gateway
|
103
|
-
APP_PORT: ${
|
109
|
+
APP_PORT: ${APP_GATEWAY_PORT:-8080}
|
104
110
|
APP_RMQ_CONNECTION: ${APP_CONTAINER_RMQ_CONNECTION:-amqp://guest:guest@rabbitmq/}
|
105
111
|
APP_KAFKA_BOOTSTRAP_SERVERS: ${APP_CONTAINER_KAFKA_BOOTSTRAP_SERVERS:-redpanda:9092}
|
106
112
|
APP_ENABLE_MESSAGE_CONSUMER: false
|
107
113
|
APP_ENABLE_RPC_SERVER: false
|
114
|
+
APP_ENABLE_API: true
|
115
|
+
APP_ENABLE_FRONTEND: true
|
108
116
|
ports:
|
109
|
-
- "${
|
117
|
+
- "${APP_GATEWAY_HOST_PORT:-8080}:${APP_GATEWAY_PORT:-8080}"
|
110
118
|
restart: on-failure
|
111
119
|
profiles:
|
112
|
-
- 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
|