forked from botpress/botpress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTiltfile
164 lines (131 loc) · 3.57 KB
/
Tiltfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# constants
## ports
OPENAPI_GENERATOR_SERVER_PORT = 8081
READINESS_PORT = 8082
## commands
GENERATE_CLIENT_RESSOURCES = ['pnpm-install', 'openapi-generator-server', 'readiness', 'generate-client']
BUILD_PACKAGES_RESSOURCES = GENERATE_CLIENT_RESSOURCES + ['build-client', 'build-sdk', 'build-cli']
BUILD_ALL_RESSOURCES = BUILD_PACKAGES_RESSOURCES + ['build-integrations', 'add-integrations', 'build-bots']
COMMAND_RESSOURCES = {
'generate-client': GENERATE_CLIENT_RESSOURCES,
'build-packages': BUILD_PACKAGES_RESSOURCES,
'build-all': BUILD_ALL_RESSOURCES
}
AVAILABLE_COMMANDS = [k for k in COMMAND_RESSOURCES.keys()]
# config
config.define_string('cmd')
cfg = config.parse()
command = cfg.get('cmd', 'build-all')
if command not in AVAILABLE_COMMANDS:
fail('command must be one of %s' % AVAILABLE_COMMANDS)
enabled_services = COMMAND_RESSOURCES[command]
config.clear_enabled_resources()
config.set_enabled_resources(enabled_services)
# resources
## pnpm install
local_resource(
name='pnpm-install',
cmd='pnpm install',
labels=['scripts'],
)
## openapi-generator-server
openapi_generator_resource = {
'image': 'botpress/openapi-generator-online',
'ports': ['%s:8080' % OPENAPI_GENERATOR_SERVER_PORT],
'restart': 'always',
}
docker_compose(encode_yaml({
'version': '3.5',
'services': {
'openapi-generator-server': openapi_generator_resource,
},
}))
dc_resource(name='openapi-generator-server', labels=['utils'])
## readiness
local_resource(
name="readiness",
allow_parallel=True,
serve_cmd='pnpm ready',
serve_env={
'PORT': '%s' % READINESS_PORT,
'LOG_LEVEL': 'info',
'CONFIG': encode_json([
{ 'type': 'http', 'name': 'openapi-generator-server', 'url': 'http://localhost:%s' % OPENAPI_GENERATOR_SERVER_PORT },
]),
},
labels=['utils'],
readiness_probe=probe(http_get=http_get_action(port=READINESS_PORT, path='/ready'), period_secs=1, failure_threshold=10),
resource_deps=[
'openapi-generator-server',
'pnpm-install',
]
)
## generate client
local_resource(
name='generate-client',
allow_parallel=True,
dir='packages/client',
cmd='pnpm generate',
env={
'OPENAPI_GENERATOR_ENDPOINT': 'http://localhost:%s' % OPENAPI_GENERATOR_SERVER_PORT,
},
labels=['client'],
resource_deps=['readiness']
)
## build client
local_resource(
name='build-client',
allow_parallel=True,
dir='packages/client',
cmd='pnpm build',
labels=['client'],
resource_deps=['generate-client'],
deps=["./packages/client"]
)
## build sdk
local_resource(
name='build-sdk',
allow_parallel=True,
dir='packages/sdk',
cmd='pnpm build',
labels=['sdk'],
resource_deps=['build-client'],
deps=["./packages/sdk"]
)
## build cli
local_resource(
name='build-cli',
allow_parallel=True,
dir='packages/cli',
cmd='pnpm build',
labels=['cli'],
resource_deps=['build-sdk'],
deps=["./packages/cli"]
)
## build integrations
local_resource(
name='build-integrations',
allow_parallel=True,
cmd='pnpm -r --stream -F @botpresshub/* exec bp build --source-map',
labels=['integrations'],
resource_deps=['build-cli'],
deps=["./integrations"]
)
## build bots
bot_filter = ".\\bots\\*" if os.name == 'nt' else './bots/*'
local_resource(
name='add-integrations',
allow_parallel=True,
cmd='pnpm -r --stream -F "%s" run integrations' % bot_filter,
labels=['bots'],
resource_deps=['build-integrations'],
deps=["./bots"]
)
local_resource(
name='build-bots',
allow_parallel=True,
cmd='pnpm -r --stream -F "%s" exec bp build --source-map' % bot_filter,
labels=['bots'],
resource_deps=['add-integrations'],
deps=["./bots"]
)