forked from sitn/sitn-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy
30 lines (24 loc) · 801 Bytes
/
deploy
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# SITN deploy helper
import os
import subprocess
def load_env_file():
with open(".env", encoding="utf-8") as env_file:
for line in env_file:
line = line.strip()
if line and not line.startswith("#"):
key, value = line.split("=", 1)
os.environ[key] = value
if __name__ == "__main__":
cmd = ["docker", "compose", "build"]
print(" ".join(cmd))
subprocess.check_call(cmd)
cmd = ["docker", "compose", "push"]
print(" ".join(cmd))
subprocess.check_call(cmd)
load_env_file()
print(f"Deploying to {os.environ['DOCKER_HOST']}")
cmd = ["docker", "compose", "up", "-d"]
print(" ".join(cmd))
subprocess.check_call(cmd)