-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.py
executable file
·54 lines (42 loc) · 1.2 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
48
49
50
51
52
53
54
#!/usr/bin/env python
# -*- coding: utf8 -*-
import os
import sys
import flask.ext.script
import jinja2
import shcmd
from chulai_builder import create_app, paas
__curdir__ = os.path.realpath(os.path.dirname(__file__))
app = create_app(os.path.join(__curdir__, "config.cfg"))
manager = flask.ext.script.Manager(app)
@manager.command
def build(env):
ENVS = dict(
base="16.04",
node="6.11.0",
ruby="2.3.0"
)
with shcmd.cd(os.path.join(__curdir__, "images")):
template = jinja2.Template(open("{0}.dockerfile".format(env)).read())
dockerfile = template.render(paas=paas)
try:
with open("Dockerfile", "wt") as df:
df.write(dockerfile)
res = paas.docker.build(
".",
rm=True,
nocache=True,
tag="{0}/{1}:{2}".format(paas.docker_registry, env, ENVS[env])
)
for line in res:
print(line)
finally:
shcmd.rm("Dockerfile")
print(env, paas)
@manager.command
def test():
import nose
with app.app_context():
nose.run(argv=list(sys.argv) + ["tests"])
if __name__ == "__main__":
manager.run()