-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile-dev
218 lines (171 loc) · 8.88 KB
/
Makefile-dev
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# Cloud Object Storage instance name
COS_INSTANCE_NAME ?= cos-choirless-dev
COS_REGION ?= eu-gb
COS_ENDPOINT = s3.private.eu-gb.cloud-object-storage.appdomain.cloud
# Regional buckets in above Cloud Object Storage instance
RAW_BUCKET_NAME ?= choirless-videos-raw-dev
CONVERTED_BUCKET_NAME ?= choirless-videos-converted-dev
TRIMMED_BUCKET_NAME ?= choirless-videos-trimmed-dev
DEFINITION_BUCKET_NAME ?= choirless-videos-definition-dev
PREVIEW_BUCKET_NAME ?= choirless-videos-preview-dev
FINAL_PARTS_BUCKET_NAME ?= choirless-videos-final-parts-dev
FINAL_BUCKET_NAME ?= choirless-videos-final-dev
STATUS_BUCKET_NAME ?= choirless-videos-status-dev
MISC_BUCKET_NAME ?= choirless-videos-misc-dev
# Namespace functions will be created int
NAMESPACE_NAME ?= choirless-dev
# Choirless API details
CHOIRLESS_API_URL ?= https://choirless-api.eu-gb.mybluemix.net/
CHOIRLESS_API_KEY ?=
RENDERER_KEY ?=
# Docker images
PYTHON_IMAGE ?= choirless/choirless_py_actions:release-0.20
NODEJS_IMAGE ?= choirless/choirless_js_actions:release-0.20
# MQTT details
MQTT_BROKER ?= mqtt.eclipse.org:1883
normalbuild: clean package build
build: actions sequences triggers rules list
fullclean: clean deletenamespace
fullbuild: namespace cos-auth build
deletenamespace:
ic fn namespace delete $${namespace}
clean:
ibmcloud fn property set --namespace $(NAMESPACE_NAME)
$(eval NAMESPACE_ID := $(shell ibmcloud fn property get --namespace | cut -f 3))
ic fn trigger list /$(NAMESPACE_ID) | grep "/$(NAMESPACE_ID)" | cut -d ' ' -f 1 | xargs -n1 ic fn trigger delete
ic fn action list /$(NAMESPACE_ID) | grep "/$(NAMESPACE_ID)" | cut -d ' ' -f 1 | xargs -n1 ic fn action delete
ic fn rule list /$(NAMESPACE_ID) | grep "/$(NAMESPACE_ID)" | cut -d ' ' -f 1 | xargs -n1 ic fn rule delete
ic fn package list /$(NAMESPACE_ID) | grep "/$(NAMESPACE_ID)" | cut -d ' ' -f 1 | xargs -n1 ic fn package delete
# Create buckets in COS
create-buckets:
ibmcloud cos create-bucket --bucket $(RAW_BUCKET_NAME) --ibm-service-instance-id $(COS_INSTANCE_NAME) --region $(COS_REGION)
ibmcloud cos create-bucket --bucket $(CONVERTED_BUCKET_NAME) --ibm-service-instance-id $(COS_INSTANCE_NAME) --region $(COS_REGION)
ibmcloud cos create-bucket --bucket $(TRIMMED_BUCKET_NAME) --ibm-service-instance-id $(COS_INSTANCE_NAME) --region $(COS_REGION)
ibmcloud cos create-bucket --bucket $(DEFINITION_BUCKET_NAME) --ibm-service-instance-id $(COS_INSTANCE_NAME) --region $(COS_REGION)
ibmcloud cos create-bucket --bucket $(FINAL_PARTS_BUCKET_NAME) --ibm-service-instance-id $(COS_INSTANCE_NAME) --region $(COS_REGION)
ibmcloud cos create-bucket --bucket $(PREVIEW_BUCKET_NAME) --ibm-service-instance-id $(COS_INSTANCE_NAME) --region $(COS_REGION)
ibmcloud cos create-bucket --bucket $(FINAL_BUCKET_NAME) --ibm-service-instance-id $(COS_INSTANCE_NAME) --region $(COS_REGION)
ibmcloud cos create-bucket --bucket $(STATUS_BUCKET_NAME) --ibm-service-instance-id $(COS_INSTANCE_NAME) --region $(COS_REGION)
ibmcloud cos create-bucket --bucket $(MISC_BUCKET_NAME) --ibm-service-instance-id $(COS_INSTANCE_NAME) --region $(COS_REGION)
# Create and set namespace
namespace:
ibmcloud fn namespace create $(NAMESPACE_NAME) --description "Choirless DEV video processing service"
ibmcloud fn property set --namespace $(NAMESPACE_NAME)
# Prepare namespace for Cloud Object Storage triggers
cos-auth:
ibmcloud iam authorization-policy-create functions cloud-object-storage "Notifications Manager" --source-service-instance-name $(NAMESPACE_NAME) --target-service-instance-name $(COS_INSTANCE_NAME)
# Create the package
package:
ibmcloud fn package update choirless \
--param CHOIRLESS_API_URL $(CHOIRLESS_API_URL) \
--param CHOIRLESS_API_KEY $(CHOIRLESS_API_KEY) \
--param ENDPOINT $(COS_ENDPOINT) \
--param geo $(COS_REGION) \
--param auth $(RENDERER_KEY) \
--param mqtt_broker $(MQTT_BROKER) \
--param definition_bucket $(DEFINITION_BUCKET_NAME) \
--param raw_bucket $(RAW_BUCKET_NAME) \
--param converted_bucket $(CONVERTED_BUCKET_NAME) \
--param trimmed_bucket $(TRIMMED_BUCKET_NAME) \
--param final_parts_bucket $(FINAL_PARTS_BUCKET_NAME) \
--param preview_bucket $(PREVIEW_BUCKET_NAME) \
--param final_bucket $(FINAL_BUCKET_NAME) \
--param status_bucket $(STATUS_BUCKET_NAME) \
--param misc_bucket $(MISC_BUCKET_NAME)
# Bind COS instance to the package
ibmcloud fn service bind cloud-object-storage choirless --instance $(COS_INSTANCE_NAME)
# Actions
actions: convert_format calculate_alignment trim_clip \
renderer renderer_compositor_main renderer_compositor_child renderer_final \
snapshot
# Convert format
convert_format:
ibmcloud fn action update choirless/convert_format python/convert_format.py \
--docker $(PYTHON_IMAGE) --timeout 600000 --memory 512
# Calculate alignment
calculate_alignment:
ibmcloud fn action update choirless/calculate_alignment python/calculate_alignment.py \
--docker $(PYTHON_IMAGE) --timeout 600000 --memory 2048
# Trim clip
trim_clip:
ibmcloud fn action update choirless/trim_clip python/trim_clip.py \
--docker $(PYTHON_IMAGE) --timeout 600000 --memory 512
# Renderer front end
renderer:
ibmcloud fn action update choirless/renderer js/renderer.js \
--docker $(NODEJS_IMAGE) --memory 2048 -t 600000 \
--web true --web-secure $(RENDERER_KEY)
# Renderer main process
renderer_compositor_main:
ibmcloud fn action update choirless/renderer_compositor_main js/renderer_compositor_main.js \
--docker $(NODEJS_IMAGE)
# Renderer child process
renderer_compositor_child:
ibmcloud fn action update choirless/renderer_compositor_child python/renderer_compositor_child.py \
--docker $(PYTHON_IMAGE) --timeout 600000 --memory 2048
# Renderer final process
renderer_final:
ibmcloud fn action update choirless/renderer_final python/renderer_final.py \
--docker $(PYTHON_IMAGE) --timeout 600000 --memory 2048
# Snapshot
snapshot:
ibmcloud fn action update choirless/snapshot python/snapshot.py \
--docker $(PYTHON_IMAGE) --timeout 600000 --memory 2048
# Status report
status:
ibmcloud fn action update choirless/status python/status.py
sequences: calc_and_trim
# Calc alignment and Trim amd stitch
calc_and_trim:
ibmcloud fn action update choirless/calc_and_trim --sequence choirless/calculate_alignment,choirless/trim_clip
triggers: bucket_raw_upload_trigger bucket_converted_upload_trigger \
bucket_trimmed_upload_trigger bucket_definition_upload_trigger \
bucket_final_parts_upload_trigger bucket_preview_upload_trigger
# Upload to raw bucket
bucket_raw_upload_trigger:
ibmcloud fn trigger create bucket_raw_upload_trigger --feed /whisk.system/cos/changes \
--param bucket $(RAW_BUCKET_NAME) --param event_types write
# Upload to converted bucket
bucket_converted_upload_trigger:
ibmcloud fn trigger create bucket_converted_upload_trigger --feed /whisk.system/cos/changes \
--param bucket $(CONVERTED_BUCKET_NAME) --param event_types write
# Upload to trimmed bucket
bucket_trimmed_upload_trigger:
ibmcloud fn trigger create bucket_trimmed_upload_trigger --feed /whisk.system/cos/changes \
--param bucket $(TRIMMED_BUCKET_NAME) --param event_types write
# Upload to definition bucket
bucket_definition_upload_trigger:
ibmcloud fn trigger create bucket_definition_upload_trigger --feed /whisk.system/cos/changes \
--param bucket $(DEFINITION_BUCKET_NAME) --param event_types write
# Upload to final parts
bucket_final_parts_upload_trigger:
ibmcloud fn trigger create bucket_final_parts_upload_trigger --feed /whisk.system/cos/changes \
--param bucket $(FINAL_PARTS_BUCKET_NAME) --param event_types write
# Upload to preview bucket
bucket_preview_upload_trigger:
ibmcloud fn trigger create bucket_preview_upload_trigger --feed /whisk.system/cos/changes \
--param bucket $(PREVIEW_BUCKET_NAME) --param event_types write --param suffix ".mp4"
rules: bucket_raw_upload_rule bucket_converted_upload_rule \
bucket_trimmed_upload_rule bucket_definition_upload_rule \
bucket_final_parts_upload_rule bucket_preview_upload_rule
# Upload to raw bucket
bucket_raw_upload_rule:
ibmcloud fn rule update bucket_raw_upload_rule bucket_raw_upload_trigger choirless/convert_format
# Upload to converted bucket
bucket_converted_upload_rule:
ibmcloud fn rule update bucket_converted_upload_rule bucket_converted_upload_trigger choirless/calc_and_trim
# Upload to trimmed bucket
bucket_trimmed_upload_rule:
ibmcloud fn rule update bucket_trimmed_upload_rule bucket_trimmed_upload_trigger choirless/renderer
# Upload to definition bucket
bucket_definition_upload_rule:
ibmcloud fn rule update bucket_definition_upload_rule bucket_definition_upload_trigger choirless/renderer_compositor_main
# Upload to final parts bucket
bucket_final_parts_upload_rule:
ibmcloud fn rule update bucket_final_parts_upload_rule bucket_final_parts_upload_trigger choirless/renderer_final
# Upload to preview bucket
bucket_preview_upload_rule:
ibmcloud fn rule update bucket_preview_upload_rule bucket_preview_upload_trigger choirless/snapshot
list:
# Display entities in the current namespace
ibmcloud fn list