forked from nasaharvest/crop-mask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
41 lines (35 loc) · 1.18 KB
/
deploy.sh
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
# exit when any command fails
set -e
# Ensure the models on DVC are being deployed
dvc pull data/models.dvc
export TAG=us-central1-docker.pkg.dev/bsos-geog-harvest1/crop-mask/crop-mask
export BUCKET=crop-mask-earthengine
export URL="https://crop-mask-grxg7bzh2a-uc.a.run.app"
export MODELS=$(
python -c \
"from pathlib import Path; \
print(' '.join([p.stem for p in Path('data/models').glob('*.pt')]))"
)
docker build . --build-arg MODELS="$MODELS" -t $TAG
docker push $TAG
gcloud run deploy crop-mask --image ${TAG}:latest \
--memory=8Gi \
--platform=managed \
--region=us-central1 \
--allow-unauthenticated \
--concurrency 10 \
--port 8080
gcloud run deploy crop-mask-management-api --image ${TAG}:latest \
--memory=4Gi \
--platform=managed \
--region=us-central1 \
--allow-unauthenticated \
--port 8081
gcloud functions deploy trigger-inference \
--source=src/trigger_inference_function \
--trigger-bucket=$BUCKET \
--allow-unauthenticated \
--runtime=python39 \
--entry-point=hello_gcs \
--set-env-vars MODELS="$MODELS",INFERENCE_HOST="$URL" \
--timeout=300s