-
Notifications
You must be signed in to change notification settings - Fork 1
/
manage.py
47 lines (31 loc) · 1.19 KB
/
manage.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
import subprocess
from typer import Typer
app = Typer()
@app.command(name="start")
def run_containers(show_logs: bool = True, build: bool = False):
command = "docker compose up"
if not show_logs:
command = f"{command} -d"
if build:
subprocess.run("docker compose build", shell=True)
subprocess.run('docker image prune --force --filter "dangling=true"', shell=True)
subprocess.run(command, shell=True)
@app.command(name="stop")
def stop_containers(drop_volumes: bool = False):
if drop_volumes:
command = "docker compose down --volumes"
else:
command = "docker compose stop"
subprocess.run(command, shell=True)
@app.command(name="build")
def rebuild_api_image():
subprocess.run("docker build . -t spectratrace-api", shell=True)
subprocess.run("docker build ./queue -t spectratrace-queue", shell=True)
subprocess.run('docker image prune --force --filter "dangling=true"', shell=True)
@app.command(name="run-tests")
def run_tests():
subprocess.run("coverage run -m pytest", shell=True)
subprocess.run("coverage report", shell=True)
subprocess.run("coverage html", shell=True)
if __name__ == "__main__":
app()