-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_app_update.sh
executable file
·85 lines (64 loc) · 2.05 KB
/
run_app_update.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
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
#!/bin/bash
# today's date
today=`date +'%Y-%m-%d'`
date_mod_10=$((`date +'%d'`%10))
# data paths
azurepath='../blitstore/blitshare'
reportpath="$azurepath/reports/scraper"
# postgres
pgpath="$azurepath/pg"
pgfile="$pgpath/param.txt"
# webapp Docker
dockerpath="webapp"
# webapp on Azure
AZURE_CONTAINER_REGISTRY='blitscanappcontainers.azurecr.io'
WEBAPPNAME='blitscanapp'
IMGNAME='blitscanpg'
# (2) update DOI database from CrossRef - and use DOIs to find missing dates
# - processes in blocks (default size 50), max 1000 DOIs before writing to d/b
# !! RUN LOCALLY - STILL DOESN'T WORK ON AVM
Rscript ./scrape/update_DOI_data.R $pgfile
# (3) download Wiley SCB pdf files
# NEEDS EDITING TO AVOID STORING PDFS
#python3 ./scrape/get_wiley_pdf.py $pgfile $wileypdf
# dashboard (R markdown)
R -e "rmarkdown::render('./webapp/dashboard.Rmd',
rmarkdown::html_document(toc = TRUE)
)"
cp ./webapp/dashboard.html $dockerpath/www
mv ./webapp/dashboard.html $reportpath/dashboard-$today.html
########################
# WEBAPP DEPLOYMENT
# build docker image(s)
docker build -t $AZURE_CONTAINER_REGISTRY/$IMGNAME $dockerpath
########################
# TO TEST LOCALLY:
#dir=`pwd`
#cd $dockerpath
#docker build -t $IMGNAME .
#open -g $AZURE_VOLUME
#docker run --rm \
# -dp 3838:3838 \
# -v /Volumes/blitshare:/srv/shiny-server/blitshare \
# -v $(pwd):/srv/shiny-server \
# -w /srv/shiny-server \
# $IMGNAME
#dockerid=`docker ps | cut -d' ' -f1 | tail -n 1`
#docker exec -ti $dockerid /bin/bash
#docker kill $dockerid
#docker rmi -f $IMGNAME
#cd $dir
# NOTE the argument --no-cache solved a thorny conflict which prevented installation of libpq-dev.
########################
# authenticate to Azure if needed
# ... and push to cloud
az acr login -n $AZURE_CONTAINER_REGISTRY
docker push $AZURE_CONTAINER_REGISTRY/$IMGNAME
# clean up local Docker
docker rmi -f $AZURE_CONTAINER_REGISTRY/$IMGNAME
# restart container
az webapp restart \
--resource-group $AZURE_RESOURCE_GROUP \
--name $WEBAPPNAME
# report
echo "Update complete."