-
Notifications
You must be signed in to change notification settings - Fork 3
349 lines (341 loc) · 12 KB
/
build_publish.yml
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
name: Build and Publish Docker
on:
workflow_dispatch:
inputs:
push:
description: 'Push to dockerhub'
type: boolean
default: false
jobs:
build-and-publish-docker:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Read docker name
id: yaml-docker-name
uses: jbutcher5/read-yaml@main
with:
file: 'build.yml'
key-path: '["docker_image_name"]'
- name: Read docker version
id: yaml-docker-version
uses: jbutcher5/read-yaml@main
with:
file: 'build.yml'
key-path: '["docker_image_version"]'
- name: Generate docker tag
env:
GITHUB_BRANCH: ${{ github.ref }}
docker_image_name: ${{ steps.yaml-docker-name.outputs.data }}
docker_image_version: ${{ steps.yaml-docker-version.outputs.data }}
run: |
branch_name=${GITHUB_BRANCH#refs/heads/}
echo "branch_name=${GITHUB_BRANCH#refs/heads/}" >> $GITHUB_ENV
if [[ "$branch_name" = "master" ]]
then
mType=""
else
mType="dev"
fi
echo "docker_tag=$docker_image_name:$mType$docker_image_version" >> $GITHUB_ENV
echo "docker_tag_latest=$docker_image_name:${mType}latest" >> $GITHUB_ENV
- name: Login to Docker Hub
if: ${{ github.event.inputs.push == 'true' }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event.inputs.push == 'true' }}
no-cache: true
tags: |
${{ env.docker_tag }}
${{ env.docker_tag_latest }}
- name: Run Ades
run: docker-compose up -d
- name: "Test1: List Services"
run: curl http://localhost/ogc-api/processes | jq
- name: "Test2: Deploy dnbr service"
run: |
curl --request POST 'http://localhost/ogc-api/processes/' \
--header 'Content-Type: application/cwl' \
--data-raw '$graph:
- class: Workflow
label: dNBR - produce the delta normalized difference between NIR and SWIR 22 over a pair of stac items
doc: dNBR - produce the delta normalized difference between NIR and SWIR 22 over a pair of stac items
id: dnbr
requirements:
- class: ScatterFeatureRequirement
- class: SubworkflowFeatureRequirement
- class: MultipleInputFeatureRequirement
inputs:
pre_stac_item:
doc: Pre-event Sentinel-2 item
type: string
post_stac_item:
doc: Post-event Sentinel-2 item
type: string
aoi:
doc: area of interest as a bounding box
type: string
bands:
type: string[]
default: ["B8A", "B12", "SCL"]
outputs:
stac:
outputSource:
- node_stac/stac
type: Directory
steps:
node_nbr:
run: "#nbr_wf"
in:
stac_item: [pre_stac_item, post_stac_item]
aoi: aoi
out:
- nbr
scatter: stac_item
scatterMethod: dotproduct
node_dnbr:
run: "#dnbr_clt"
in:
tifs:
source: node_nbr/nbr
out:
- dnbr
node_cog:
run: "#gdal_cog_clt"
in:
tif:
source: [node_dnbr/dnbr]
out:
- cog_tif
node_stac:
run: "#stacme_clt"
in:
tif:
source: [node_cog/cog_tif]
pre_stac_item: pre_stac_item
post_stac_item: post_stac_item
out:
- stac
- class: Workflow
label: NBR - produce the normalized difference between NIR and SWIR 22 and convert to COG
doc: NBR - produce the normalized difference between NIR and SWIR 22 and convert to COG
id: nbr_wf
requirements:
- class: ScatterFeatureRequirement
- class: SubworkflowFeatureRequirement
inputs:
stac_item:
doc: Sentinel-2 item
type: string
aoi:
doc: area of interest as a bounding box
type: string
bands:
type: string[]
default: ["B8A", "B12", "SCL"]
outputs:
nbr:
outputSource:
- node_cog/cog_tif
type: File
steps:
node_stac:
run: "#asset_single_clt"
in:
stac_item: stac_item
asset: bands
out:
- asset_href
scatter: asset
scatterMethod: dotproduct
node_subset:
run: "#translate_clt"
in:
asset:
source: node_stac/asset_href
bbox: aoi
out:
- tifs
scatter: asset
scatterMethod: dotproduct
node_nbr:
run: "#band_math_clt"
in:
stac_item: stac_item
tifs:
source: [node_subset/tifs]
out:
- nbr_tif
node_cog:
run: "#gdal_cog_clt"
in:
tif:
source: [node_nbr/nbr_tif]
out:
- cog_tif
- class: CommandLineTool
id: asset_single_clt
requirements:
DockerRequirement:
dockerPull: docker.io/curlimages/curl:latest
ShellCommandRequirement: {}
InlineJavascriptRequirement: {}
baseCommand: [curl, -s]
arguments:
- $( inputs.stac_item )
stdout: message
inputs:
stac_item:
type: string
asset:
type: string
outputs:
asset_href:
type: Any
outputBinding:
glob: message
loadContents: true
outputEval: |-
${ var assets = JSON.parse(self[0].contents).assets;
return assets[inputs.asset].href; }
- class: CommandLineTool
id: translate_clt
requirements:
InlineJavascriptRequirement: {}
DockerRequirement:
dockerPull: docker.io/osgeo/gdal
baseCommand: gdal_translate
arguments:
- -projwin
- valueFrom: ${ return inputs.bbox.split(",")[0]; }
- valueFrom: ${ return inputs.bbox.split(",")[3]; }
- valueFrom: ${ return inputs.bbox.split(",")[2]; }
- valueFrom: ${ return inputs.bbox.split(",")[1]; }
- -projwin_srs
- valueFrom: ${ return inputs.epsg; }
- valueFrom: "${ if (inputs.asset.startsWith(\"http\")) {\n\n return \"/vsicurl/\" + inputs.asset; \n\n } else { \n\n return inputs.asset;\n\n } \n}\n"
- valueFrom: ${ return inputs.asset.split("/").slice(-1)[0]; }
inputs:
asset:
type: string
bbox:
type: string
epsg:
type: string
default: "EPSG:4326"
outputs:
tifs:
outputBinding:
glob: '\''*.tif'\''
type: File
- class: CommandLineTool
id: band_math_clt
requirements:
InlineJavascriptRequirement: {}
DockerRequirement:
dockerPull: docker.io/terradue/otb-7.2.0
baseCommand: otbcli_BandMathX
arguments:
- -out
- valueFrom: ${ return inputs.stac_item.split("/").slice(-1)[0] + ".tif"; }
- -exp
- '\''(im3b1 == 8 or im3b1 == 9 or im3b1 == 0 or im3b1 == 1 or im3b1 == 2 or im3b1 == 10 or im3b1 == 11) ? -2 : (im1b1 - im2b1) / (im1b1 + im2b1)'\''
inputs:
tifs:
type: File[]
inputBinding:
position: 5
prefix: -il
separate: true
stac_item:
type: string
outputs:
nbr_tif:
outputBinding:
glob: "*.tif"
type: File
- class: CommandLineTool
id: gdal_cog_clt
requirements:
InlineJavascriptRequirement: {}
DockerRequirement:
dockerPull: osgeo/gdal
baseCommand: gdal_translate
arguments:
- -co
- COMPRESS=DEFLATE
- -of
- COG
- valueFrom: ${ return inputs.tif }
- valueFrom: ${ return inputs.tif.basename.replace(".tif", "") + '\''_cog.tif'\''; }
inputs:
tif:
type: File
outputs:
cog_tif:
outputBinding:
glob: '\''*_cog.tif'\''
type: File
- class: CommandLineTool
id: dnbr_clt
requirements:
InlineJavascriptRequirement: {}
DockerRequirement:
dockerPull: docker.io/terradue/otb-7.2.0
baseCommand: otbcli_BandMathX
arguments:
- -out
- dnbr.tif
- -exp
- '\''(im1b1 == -2 or im2b1 == -2 ) ? -20000 : (im2b1 - im1b1) * 10000'\''
inputs:
tifs:
type: File[]
inputBinding:
position: 5
prefix: -il
separate: true
outputs:
dnbr:
outputBinding:
glob: "dnbr.tif"
type: File
- class: CommandLineTool
id: stacme_clt
requirements:
InlineJavascriptRequirement: {}
DockerRequirement:
dockerPull: registry.gitlab.com/app-packages/terradue/dnbr-sentinel-2-cog/stacme:0.1.0-develop
baseCommand: stacme
arguments: []
inputs:
tif:
type: File
inputBinding:
position: 1
pre_stac_item:
type: string
inputBinding:
position: 2
post_stac_item:
type: string
inputBinding:
position: 3
outputs:
stac:
outputBinding:
glob: "."
type: Directory
cwlVersion: v1.0
$namespaces:
s: https://schema.org/
s:softwareVersion: 0.1.0
schemas:
- http://schema.org/version/9.0/schemaorg-current-http.rdf' | jq