-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker.py
36 lines (28 loc) · 849 Bytes
/
docker.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
import argparse
import os
compose_prod = "docker-compose.yml"
compose_dev = filename = "docker-compose.dev.yml"
parser = argparse.ArgumentParser(description="Runs docker containers.")
parser.add_argument(
"action",
type=str,
help="Specify docker action.",
choices=["up", "down", "build", "restart", "start", "stop", "setup"],
)
parser.add_argument(
"-p", "--production", action="store_true", help="Run in production mode."
)
parser.add_argument(
"-d", "--detached", action="store_true", help="Run in detached mode."
)
args = parser.parse_args()
action = args.action
if args.production:
filename = compose_prod
if args.action == "setup":
action = "exec web sh scripts/setup.sh"
cmd = "docker-compose -f %s %s" % (filename, action)
if args.detached:
cmd += " -d"
print("Running: %s\n" % cmd)
os.system(cmd)