-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTiltfile
More file actions
174 lines (143 loc) · 4.6 KB
/
Copy pathTiltfile
File metadata and controls
174 lines (143 loc) · 4.6 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
## Gateway API Tiltfile
##
## Loki Sinclair <loki.sinclair@hdruk.ac.uk>
##
# Load Extensions
load("ext://uibutton", "cmd_button", "location", "text_input")
update_settings(suppress_unused_image_warnings=["hdruk/mysql"])
# Configure extra UI elements
cmd_button(
name="gateway-api-config-clear",
text="Config clear",
resource="gateway-api",
argv=["sh", "-c", "php artisan optimize:clear && php artisan config:clear && php artisan cache:clear"],
icon_name="refresh",
)
cmd_button(
name="gateway-api-run-tests",
text="Run Pest",
resource="gateway-api",
argv=[
"sh", "-c",
"kubectl exec -it $(kubectl get pod -l app=gateway-api -o jsonpath='{.items[0].metadata.name}') -- composer run pest"
],
icon_name="search_off",
)
cmd_button(
name="gateway-api-run-unit-tests",
text="Run PHPUnit",
resource="gateway-api",
argv=[
"sh", "-c",
"kubectl exec -it $(kubectl get pod -l app=gateway-api -o jsonpath='{.items[0].metadata.name}') -- php -d memory_limit=2048M ./vendor/bin/phpunit --testdox"
],
icon_name="search_off",
)
cmd_button(
name="gateway-api-migrate",
text="Migrate DB",
resource="gateway-api",
argv=[
"kubectl",
"exec",
"-it",
"gateway-api",
"--",
"php",
"artisan",
"migrate:fresh",
],
# argv=['php', 'artisan', 'migrate:fresh'],
icon_name="database",
)
cmd_button(
name="gateway-api-seed",
text="DB Seed",
resource="gateway-api",
argv=["kubectl", "exec", "-it", "gateway-api", "--", "php", "artisan", "db:seed"],
icon_name="table",
)
cmd_button(
name="gateway-api-shell",
text="Open Shell",
resource="gateway-api",
argv=[
"osascript", "-e",
'tell application "iTerm2" to activate',
"-e",
'tell application "iTerm2"',
"-e",
'set newWindow to (create window with default profile)',
"-e",
'delay 2',
"-e",
'tell current session of newWindow',
"-e",
'write text "kubectl exec -it deploy/gateway-api -- bash"',
"-e",
'end tell',
"-e",
'end tell',
],
icon_name="terminal",
)
# Load in any locally set config
cfg = read_json("tiltconf.json")
include(cfg.get("gatewayWeb2Root") + "/Tiltfile")
# Load our service layer for deployment - if enabled
if cfg.get("dtaWebEnabled"):
include(cfg.get("dtaWebRoot") + "/Tiltfile")
if cfg.get("traserEnabled"):
include(cfg.get("traserServiceRoot") + "/Tiltfile")
if cfg.get("tedEnabled"):
include(cfg.get("tedServiceRoot") + "/Tiltfile")
if cfg.get("gmiEnabled"):
include(cfg.get("gmiServiceRoot") + "/Tiltfile")
if cfg.get("searchEnabled"):
include(cfg.get("searchServiceRoot") + "/Tiltfile")
if cfg.get("elasticEnabled"):
include(cfg.get("elasticServiceRoot") + "/Tiltfile")
if cfg.get("qbEnabled"):
include(cfg.get("qbServiceRoot") + "/Tiltfile")
if cfg.get("darasEnabled"):
include(cfg.get("darasServiceRoot") + "/Tiltfile")
if cfg.get('clamavEnabled'):
include(cfg.get('clamavServiceRoot') + '/Tiltfile')
if cfg.get("mysqlEnabled"):
include(cfg.get("mysqlRoot") + "/Tiltfile")
if cfg.get("mailhogEnabled"):
include(cfg.get("mailhogRoot") + "/Tiltfile")
if cfg.get("datasetServiceEnabled"):
include(cfg.get("datasetServiceRoot") + "/Tiltfile")
## Implements a watcher for local file changes to automatically
## fix linting issues in real-time, locally.
local_resource('linting', cmd='composer run lint', deps=['./'])
docker_build(
ref="hdruk/" + cfg.get("name"),
context=".",
build_args={
"TRASER_ENABLED": "1" if cfg.get("traserEnabled") else "0",
"TED_ENABLED": "1" if cfg.get("tedEnabled") else "0",
"GMI_ENABLED": "1" if cfg.get("gmiEnabled") else "0",
"SEARCH_ENABLED": "1" if cfg.get("searchEnabled") else "0",
},
live_update=[
sync(".", "/var/www"),
run("composer install", trigger="./composer.lock"),
run("php artisan route:clear"),
run("php artisan cache:clear"),
run("php artisan config:clear", trigger="./.env"),
run("php artisan l5-swagger:generate"),
],
)
k8s_yaml("chart/" + cfg.get("name") + "/deployment.yaml")
k8s_yaml("chart/" + cfg.get("name") + "/service.yaml")
# k8s_resource(cfg.get("name"), port_forwards=8000, labels=["Service"])
deps = []
if cfg.get("mysqlEnabled"):
deps.append("mysql")
if cfg.get("elasticEnabled"):
deps.append("elasticsearch")
if cfg.get("mailhogEnabled"):
deps.append("mailhog")
k8s_resource(cfg.get("name"), port_forwards=8000, labels=["API"], resource_deps=deps)