99
1010load ("ext://syncback" , "syncback" )
1111
12+ # Check for --debugpy argument
13+ config .define_bool ("debugpy" , False , "Enable debugpy debugging support" )
14+ cfg = config .parse ()
15+ enable_debugpy = cfg .get ("debugpy" , False )
16+
1217docker_build (
1318 "backend" ,
1419 context = "backend" ,
@@ -29,9 +34,46 @@ docker_build(
2934)
3035{% endif % }
3136
32- k8s_yaml (
33- kustomize ("./k8s/local/" )
34- )
37+ def patch_debugpy_support (k8s_objects ):
38+ """Patch the backend deployment to add debugpy support"""
39+ return blob (
40+ str (k8s_objects ) +
41+ """
42+ ---
43+ apiVersion: v1
44+ kind: Service
45+ metadata:
46+ name: backend
47+ spec:
48+ ports:
49+ - port: 5678
50+ targetPort: 5678
51+ name: debug
52+ ---
53+ apiVersion: apps/v1
54+ kind: Deployment
55+ metadata:
56+ name: backend
57+ spec:
58+ template:
59+ spec:
60+ containers:
61+ - name: backend
62+ command: ["python", "-m", "debugpy", "--listen", "0.0.0.0:5678", "manage.py", "runserver", "0.0.0.0:8000"]
63+ ports:
64+ - name: debug
65+ containerPort: 5678
66+ """
67+ )
68+
69+ # Load base kubernetes configuration
70+ k8s_objects = kustomize ("./k8s/local/" )
71+
72+ # Apply debugpy patches if enabled
73+ if enable_debugpy :
74+ k8s_objects = patch_debugpy_support (k8s_objects )
75+
76+ k8s_yaml (k8s_objects )
3577
3678syncback (
3779 "backend-sync" ,
@@ -55,7 +97,8 @@ syncback(
5597{% if copier__create_nextjs_frontend % }
5698k8s_resource (workload = 'frontend' , port_forwards = 3000 )
5799{% endif % }
58- k8s_resource (workload = 'backend' , port_forwards = 5678 )
100+ if enable_debugpy :
101+ k8s_resource (workload = 'backend' , port_forwards = 5678 )
59102k8s_resource (workload = 'backend' , port_forwards = 8000 )
60103k8s_resource (workload = 'mailhog' , port_forwards = 8025 )
61104k8s_resource (workload = 'postgres' , port_forwards = 5432 )
0 commit comments