@@ -132,10 +132,11 @@ def get_running_pods_by_project(self, name: str):
132
132
}
133
133
return pods
134
134
135
- def _deploy_service (
135
+ def _deploy_compose_service (
136
136
self ,
137
137
project : str ,
138
- template_path : Path ,
138
+ template_paths : list [Path ] | Path ,
139
+ env_file : Path | None = None ,
139
140
env_vars : dict [str , str ] = {},
140
141
extra_args : list [str ] = [],
141
142
):
@@ -146,13 +147,21 @@ def _deploy_service(
146
147
project: The name of the project to deploy the service to.
147
148
template_path: The path to the template to use for the service.
148
149
env_vars: The environment variables to set.
150
+ env_file: The path to the environment file to use for the service.
149
151
extra_args: Extra arguments to pass to the compose command.
150
152
"""
153
+ if isinstance (template_paths , Path ):
154
+ template_paths = [template_paths ]
155
+
156
+ file_overlays = []
157
+ for path in template_paths :
158
+ file_overlays .extend (["-f" , str (path )])
159
+
151
160
new_env = {** os .environ , ** env_vars }
152
161
cmd = [
153
162
* self .compose ,
154
- "-f" ,
155
- template_path ,
163
+ * file_overlays ,
164
+ * ([ "--env-file" , str ( env_file )] if env_file else []) ,
156
165
"-p" ,
157
166
project ,
158
167
* extra_args ,
@@ -188,24 +197,38 @@ def deploy_appwrite_lab(
188
197
error = True , message = f"Lab '{ name } ' already deployed." , data = None
189
198
)
190
199
converted_version = version .replace ("." , "_" )
200
+
201
+ # Gather paths
191
202
template_path = (
192
203
Path (__file__ ).parent
193
204
/ "templates"
194
205
/ f"docker_compose_{ converted_version } .yml"
195
206
)
207
+
208
+ twilio_shim_path = (
209
+ Path (__file__ ).parent
210
+ / "templates"
211
+ / "extras"
212
+ / "twilio-shim"
213
+ / "docker_compose.yml"
214
+ )
215
+
216
+ env_file = Path (__file__ ).parent / "templates" / "environment" / "dotenv"
196
217
if not template_path .exists ():
197
218
return Response (
198
219
error = True , message = f"Template { version } not found." , data = None
199
220
)
200
221
201
- # Override default env vars
222
+ # Override default env vars for port
202
223
env_vars = get_env_vars (self .default_env_vars )
203
224
if port != 80 :
204
225
env_vars ["_APP_PORT" ] = str (port )
205
226
206
227
# What actually deploys the initial appwrite service
207
- cmd_res = self ._deploy_service (
208
- project = name , template_path = template_path , env_vars = env_vars
228
+ cmd_res = self ._deploy_compose_service (
229
+ project = name ,
230
+ template_paths = [template_path , twilio_shim_path ],
231
+ env_file = env_file ,
209
232
)
210
233
211
234
# Deploy mail server (mailpit)
@@ -216,9 +239,7 @@ def deploy_appwrite_lab(
216
239
/ "mailpit"
217
240
/ "docker_compose.yml"
218
241
)
219
- self ._deploy_service (
220
- project = name , template_path = mailpit_template_path , env_vars = {}
221
- )
242
+ self ._deploy_compose_service (project = name , template_paths = mailpit_template_path )
222
243
# if CLI, will throw error in actual Response object
223
244
if type (cmd_res ) is Response and cmd_res .error :
224
245
return cmd_res
0 commit comments