@@ -132,10 +132,11 @@ def get_running_pods_by_project(self, name: str):
132132 }
133133 return pods
134134
135- def _deploy_service (
135+ def _deploy_compose_service (
136136 self ,
137137 project : str ,
138- template_path : Path ,
138+ template_paths : list [Path ] | Path ,
139+ env_file : Path | None = None ,
139140 env_vars : dict [str , str ] = {},
140141 extra_args : list [str ] = [],
141142 ):
@@ -144,22 +145,29 @@ def _deploy_service(
144145
145146 Args:
146147 project: The name of the project to deploy the service to.
147- template_path : The path to the template to use for the service.
148+ template_paths : The path to the template to use for the service.
148149 env_vars: The environment variables to set.
150+ env_file: The path to the environment file to use for the service.
149151 extra_args: Extra arguments to pass to the compose command.
150152 """
151- new_env = {** os .environ , ** env_vars }
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+
152160 cmd = [
153161 * self .compose ,
154- "-f" ,
155- template_path ,
162+ * file_overlays ,
163+ * ([ "--env-file" , str ( env_file )] if env_file else []) ,
156164 "-p" ,
157165 project ,
158166 * extra_args ,
159167 "up" ,
160168 "-d" ,
161169 ]
162- return self ._run_cmd_safely (cmd , envs = new_env )
170+ return self ._run_cmd_safely (cmd , envs = env_vars )
163171
164172 def deploy_appwrite_lab (
165173 self ,
@@ -188,24 +196,38 @@ def deploy_appwrite_lab(
188196 error = True , message = f"Lab '{ name } ' already deployed." , data = None
189197 )
190198 converted_version = version .replace ("." , "_" )
199+
200+ # Gather paths
191201 template_path = (
192202 Path (__file__ ).parent
193203 / "templates"
194204 / f"docker_compose_{ converted_version } .yml"
195205 )
206+
207+ twilio_shim_path = (
208+ Path (__file__ ).parent
209+ / "templates"
210+ / "extras"
211+ / "twilio-shim"
212+ / "docker_compose.yml"
213+ )
214+
215+ env_file = Path (__file__ ).parent / "templates" / "environment" / "dotenv"
196216 if not template_path .exists ():
197217 return Response (
198218 error = True , message = f"Template { version } not found." , data = None
199219 )
200220
201- # Override default env vars
221+ # Override default env vars for port
202222 env_vars = get_env_vars (self .default_env_vars )
203223 if port != 80 :
204224 env_vars ["_APP_PORT" ] = str (port )
205225
206226 # What actually deploys the initial appwrite service
207- cmd_res = self ._deploy_service (
208- project = name , template_path = template_path , env_vars = env_vars
227+ cmd_res = self ._deploy_compose_service (
228+ project = name ,
229+ template_paths = [template_path , twilio_shim_path ],
230+ env_file = env_file ,
209231 )
210232
211233 # Deploy mail server (mailpit)
@@ -216,9 +238,7 @@ def deploy_appwrite_lab(
216238 / "mailpit"
217239 / "docker_compose.yml"
218240 )
219- self ._deploy_service (
220- project = name , template_path = mailpit_template_path , env_vars = {}
221- )
241+ self ._deploy_compose_service (project = name , template_paths = mailpit_template_path )
222242 # if CLI, will throw error in actual Response object
223243 if type (cmd_res ) is Response and cmd_res .error :
224244 return cmd_res
@@ -246,6 +266,8 @@ def deploy_appwrite_lab(
246266 version = version ,
247267 url = url ,
248268 ** _kwargs ,
269+ sms_shim_url = "https://localhost:4443" ,
270+ mailpit_url = "http://localhost:8025" ,
249271 )
250272
251273 lab .generate_missing_config ()
0 commit comments