11import os
22import re
33
4- from app .utils .config import Config
4+ from app .utils .config import (
5+ API_PORT ,
6+ CADDY_ADMIN_PORT ,
7+ CADDY_HTTP_PORT ,
8+ CADDY_HTTPS_PORT ,
9+ Config ,
10+ PROXY_PORT ,
11+ SUPERTOKENS_API_PORT ,
12+ VIEW_PORT ,
13+ )
514from app .utils .protocols import LoggerProtocol
615
716from .messages import configuration_key_has_no_default_value
@@ -20,6 +29,14 @@ def __init__(
2029 config_file : str = None ,
2130 repo : str = None ,
2231 branch : str = None ,
32+ api_port : int = None ,
33+ view_port : int = None ,
34+ db_port : int = None ,
35+ redis_port : int = None ,
36+ caddy_admin_port : int = None ,
37+ caddy_http_port : int = None ,
38+ caddy_https_port : int = None ,
39+ supertokens_port : int = None ,
2340 ):
2441 self .logger = logger
2542 self .verbose = verbose
@@ -29,13 +46,71 @@ def __init__(
2946 self .config_file = config_file
3047 self .repo = repo
3148 self .branch = branch
49+ self .api_port = api_port
50+ self .view_port = view_port
51+ self .db_port = db_port
52+ self .redis_port = redis_port
53+ self .caddy_admin_port = caddy_admin_port
54+ self .caddy_http_port = caddy_http_port
55+ self .caddy_https_port = caddy_https_port
56+ self .supertokens_port = supertokens_port
3257 self ._config = Config ()
3358 self ._config .load_user_config (self .config_file )
59+ self ._user_config = None
3460 self .progress = None
3561 self .main_task = None
3662
3763 def _get_config (self , path : str ):
3864 """Base config getter - override in subclasses for specific behavior"""
65+ # Override port values if provided via command line
66+ if path == API_PORT and self .api_port is not None :
67+ return str (self .api_port )
68+ if path == VIEW_PORT and self .view_port is not None :
69+ return str (self .view_port )
70+ if path == "services.db.env.DB_PORT" and self .db_port is not None :
71+ return str (self .db_port )
72+ if path == "services.redis.env.REDIS_PORT" and self .redis_port is not None :
73+ return str (self .redis_port )
74+
75+ # Handle PROXY_PORT (which is an alias for CADDY_ADMIN_PORT)
76+ if path == PROXY_PORT :
77+ if self .caddy_admin_port is not None :
78+ return str (self .caddy_admin_port )
79+ # Fall back to CADDY_ADMIN_PORT from config, default to 2019
80+ try :
81+ return str (self ._config .get (CADDY_ADMIN_PORT ))
82+ except (KeyError , ValueError ):
83+ return "2019"
84+
85+ if path == CADDY_ADMIN_PORT and self .caddy_admin_port is not None :
86+ return str (self .caddy_admin_port )
87+ if path == CADDY_HTTP_PORT and self .caddy_http_port is not None :
88+ return str (self .caddy_http_port )
89+ if path == CADDY_HTTPS_PORT and self .caddy_https_port is not None :
90+ return str (self .caddy_https_port )
91+ if path == SUPERTOKENS_API_PORT and self .supertokens_port is not None :
92+ return str (self .supertokens_port )
93+
94+ # Handle simple key lookups for port overrides
95+ if path == "db_port" and self .db_port is not None :
96+ return str (self .db_port )
97+ if path == "redis_port" and self .redis_port is not None :
98+ return str (self .redis_port )
99+ if path == "proxy_port" and self .caddy_admin_port is not None :
100+ return str (self .caddy_admin_port )
101+ if path == "api_port" and self .api_port is not None :
102+ return str (self .api_port )
103+ if path == "view_port" and self .view_port is not None :
104+ return str (self .view_port )
105+ if path == "caddy_admin_port" and self .caddy_admin_port is not None :
106+ return str (self .caddy_admin_port )
107+ if path == "caddy_http_port" and self .caddy_http_port is not None :
108+ return str (self .caddy_http_port )
109+ if path == "caddy_https_port" and self .caddy_https_port is not None :
110+ return str (self .caddy_https_port )
111+ if path == "supertokens_api_port" and self .supertokens_port is not None :
112+ return str (self .supertokens_port )
113+
39114 return self ._config .get (path )
40115
41116 def _validate_domains (self , api_domain : str = None , view_domain : str = None ):
0 commit comments