-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtasks.py
92 lines (65 loc) · 1.93 KB
/
tasks.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
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
import os
from invoke import task # type: ignore
from dotenv import load_dotenv
load_dotenv()
env = os.environ
@task
def test(c):
c.run("pytest", pty=True)
@task
def black(c):
c.run("black .", pty=True)
@task(help={"message": "Description of the new migration."})
def db_migrate(c, message="replace this message"):
"""
Create a new alembic migration.
"""
c.run(
f"alembic revision --autogenerate -m '{message}'", pty=True, env=env
)
@task(help={"target": "Target alembic revision."})
def db_upgrade(c, target="head"):
"""
Upgrade the db to the target alembic revision.
"""
c.run(f"alembic upgrade {target}", pty=True, env=env)
@task
def dev_services(c):
c.run("docker network create property-app-net || true", hide=True)
c.run("docker-compose -f docker-compose.yml up -d", pty=True, env=env)
c.run("pg_isready", env=env)
@task(dev_services)
def dev_app(c):
c.run("property", env=env, pty=True)
@task(dev_services)
def dev_shell(c):
c.run("ipython", env=env, pty=True)
@task
def dev_client(c):
c.run("npm run dev", pty=True)
@task
def dbt_run(c):
c.run("dbt run --profiles-dir ./profiles", pty=True, env=env)
@task
def ssl_gen(c):
certbot_opts = [
"--manual",
"--config-dir nginx/.letsencrypt/",
"--work-dir nginx/.letsencrypt/work/",
"--logs-dir nginx/.letsencrypt/logs/",
"--preferred-challenges dns",
"-m ssl@almostproductive.com",
"--agree-tos",
"-d *.local.almostproductive.com",
]
c.run(f'certbot certonly {" ".join(certbot_opts)}')
c.run("cp -r nginx/.letsencrypt/live/* nginx/")
@task
def ssl_renew(c):
certbot_opts = [
"--config-dir nginx/.letsencrypt/",
"--work-dir nginx/.letsencrypt/work/",
"--logs-dir nginx/.letsencrypt/logs/",
]
c.run(f'certbot renew {" ".join(certbot_opts)}')
c.run("cp nginx/.letsencrypt/live/**/*.pem nginx/")