-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev_local.py
More file actions
executable file
·96 lines (75 loc) · 2.87 KB
/
dev_local.py
File metadata and controls
executable file
·96 lines (75 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env python3
import os
import shutil
import signal
import subprocess
import sys
import key_setup
def check_command_exists(cmd):
if not shutil.which(cmd):
print(f"Required command '{cmd}' not found in PATH.")
sys.exit(1)
def cleanup(signum=None, _=None):
print("\nShutting down Docker Compose...")
try:
subprocess.run(["docker", "compose", "-f", "docker-compose-local-dev.yml", "-f", "docker-compose.override.yml", "down"], check=True)
except Exception as exc:
print(f"Error during docker compose down: {exc}")
sys.exit(0)
def verify_local_setup_completed():
"""Check if local_setup.py has been run at least once."""
missing_components = []
# Check for node_modules directory in ui folder (created by pnpm install)
ui_node_modules = os.path.join("ui", "node_modules")
if not os.path.exists(ui_node_modules):
missing_components.append(f"UI dependencies (missing {ui_node_modules} directory)")
# Check for RSA keys (created by key_setup.py)
rsa_private_key = os.path.join("app", "src", "main", "resources", "local-dev-keys", "privateKey.pem")
if not os.path.exists(rsa_private_key):
missing_components.append(f"JWT keys (missing {rsa_private_key})")
if missing_components:
print("Error: Local setup has not been completed properly.")
print("The following components were not found:")
for component in missing_components:
print(f" - {component}")
print("\nPlease run './local_setup.py' once to set up your development environment.")
sys.exit(1)
print("Local setup verification passed.")
def start_docker_compose():
print("Starting Docker Compose...")
try:
subprocess.run(["docker", "compose", "-f", "docker-compose-local-dev.yml", "-f", "docker-compose.override.yml", "up", "-d"], check=True)
except subprocess.CalledProcessError as exception:
print(f"Failed to start Docker Compose: {exception}")
sys.exit(1)
def start_quarkus_dev():
print("Starting Quarkus Dev...")
proc = subprocess.Popen(
["./gradlew", "quarkusDev"],
cwd="app"
)
try:
proc.wait()
except KeyboardInterrupt:
print("\nInterrupted by user.")
finally:
if proc.poll() is None:
proc.terminate()
proc.wait()
cleanup()
def ensure_executed_from_repo_root():
if not key_setup.ensure_repo_root():
print("Please run this script from the repository root directory.")
sys.exit(1)
def main():
ensure_executed_from_repo_root()
check_command_exists("docker")
check_command_exists("pnpm")
check_command_exists("pre-commit")
verify_local_setup_completed()
signal.signal(signal.SIGINT, cleanup)
signal.signal(signal.SIGTERM, cleanup)
start_docker_compose()
start_quarkus_dev()
if __name__ == "__main__":
main()