-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocal_deploy.py
53 lines (48 loc) · 1.62 KB
/
local_deploy.py
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
import asyncio
import subprocess
async def docker_pull(image):
process = await asyncio.create_subprocess_shell(
f'docker pull {image}',
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
stdout, stderr = await process.communicate()
if process.returncode == 0:
print(f'Successfully pulled {image}')
else:
print(f'Failed to pull {image}: {stderr.decode()}')
async def main():
images = [
'openjdk:17',
'mysql:8.4.3',
'redis:latest',
'bitnami/grafana:latest',
'prom/prometheus:latest'
]
tasks = [docker_pull(image) for image in images]
await asyncio.gather(*tasks)
# ./gradlew clean build -x test --warning-mode all 명령어 실행
build_process = await asyncio.create_subprocess_shell(
'./gradlew clean build -x test --warning-mode all',
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
stdout, stderr = await build_process.communicate()
if build_process.returncode == 0:
print('Build successful')
else:
print(f'Build failed: {stderr.decode()}')
return
# docker compose up -d --build 명령어 실행
compose_process = await asyncio.create_subprocess_shell(
'cd ./docker && sudo docker compose up -d --build && pwd',
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
stdout, stderr = await compose_process.communicate()
if compose_process.returncode == 0:
print('Docker compose up successful')
else:
print(f'Docker compose up failed: {stderr.decode()}')
if __name__ == '__main__':
asyncio.run(main())