@@ -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 ):
@@ -146,13 +147,21 @@ def _deploy_service(
146147 project: The name of the project to deploy the service to.
147148 template_path: 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 """
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+
151160 new_env = {** os .environ , ** env_vars }
152161 cmd = [
153162 * self .compose ,
154- "-f" ,
155- template_path ,
163+ * file_overlays ,
164+ * ([ "--env-file" , str ( env_file )] if env_file else []) ,
156165 "-p" ,
157166 project ,
158167 * extra_args ,
@@ -188,24 +197,38 @@ def deploy_appwrite_lab(
188197 error = True , message = f"Lab '{ name } ' already deployed." , data = None
189198 )
190199 converted_version = version .replace ("." , "_" )
200+
201+ # Gather paths
191202 template_path = (
192203 Path (__file__ ).parent
193204 / "templates"
194205 / f"docker_compose_{ converted_version } .yml"
195206 )
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"
196217 if not template_path .exists ():
197218 return Response (
198219 error = True , message = f"Template { version } not found." , data = None
199220 )
200221
201- # Override default env vars
222+ # Override default env vars for port
202223 env_vars = get_env_vars (self .default_env_vars )
203224 if port != 80 :
204225 env_vars ["_APP_PORT" ] = str (port )
205226
206227 # 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 ,
209232 )
210233
211234 # Deploy mail server (mailpit)
@@ -216,9 +239,7 @@ def deploy_appwrite_lab(
216239 / "mailpit"
217240 / "docker_compose.yml"
218241 )
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 )
222243 # if CLI, will throw error in actual Response object
223244 if type (cmd_res ) is Response and cmd_res .error :
224245 return cmd_res
0 commit comments