1+ #! /bin/bash
2+
3+ deployDocs () {
4+ local ns=" $1 "
5+ local tag=" $2 "
6+ local typesenseFQDN=" $3 "
7+
8+ echo " Building the aifrim/lttle-docs:$tag image..."
9+ docker build --build-arg TYPESENSE_FQDN=" $typesenseFQDN " --build-arg TYPESENSE_API_KEY=" $TYPESENSE_API_KEY " -f ./docker/dockerfile . -t aifrim/lttle-docs:$tag
10+
11+ echo " Pushing the aifrim/lttle-docs:$tag image..."
12+ docker push aifrim/lttle-docs:$tag
13+
14+ echo " Deploying only the nginx-docs"
15+ lttle deploy ./lttle/docs.lttle.yaml
16+
17+ echo " Restarting the machine in namespace $ns ..."
18+ lttle machine restart --ns $ns nginx-docs
19+ }
20+
21+ deployTypeSense () {
22+ local ns=" $1 "
23+ local tag=" $2 "
24+ local docsUrl=" $3 "
25+
26+ if [[ $ns != ' main' ]]; then
27+ echo " Backing up & patching ./docker/typesense-production.config.json"
28+
29+ # Need to patch ./docker/typesense-production.config.json to scrape preview environment url
30+ cp ./docker/typesense-scraper.production.config.json ./docker/typesense-scraper.production.config.json.bak
31+ jq --arg url " $docsUrl " ' .start_urls[0].url = $url' ./docker/typesense-scraper.production.config.json.bak > ./docker/typesense-scraper.production.config.json
32+ fi
33+
34+ echo " Building the aifrim/typesense-scraper:$tag image..."
35+
36+ echo " Using config" ;
37+ bat --paging never ./docker/typesense-scraper.production.config.json
38+
39+ docker build -f ./docker/typesense-scraper.dockerfile docker -t aifrim/typesense-scraper:$tag
40+
41+ if [[ $ns != ' main' ]]; then
42+ echo " Restoring ./docker/typesense-scraper.production.config.json"
43+ cp ./docker/typesense-scraper.production.config.json.bak ./docker/typesense-scraper.production.config.json
44+ rm ./docker/typesense-scraper.production.config.json.bak
45+ fi
46+
47+ echo " Pushing the aifrim/typesense-scraper:$tag image..."
48+ docker push aifrim/typesense-scraper:$tag
49+
50+ echo " Deploying only the typesense-search"
51+ lttle deploy ./lttle/typesense.lttle.yaml
52+
53+ echo " Restarting the machine in namespace $ns ..."
54+ lttle machine restart --ns $ns typesense-search
55+ lttle machine restart --ns $ns typesense-scraper
56+ }
57+
58+ restartMachines () {
59+ local ns=" $1 "
60+
61+ echo " Restarting the machine in namespace $ns ..."
62+
63+ lttle machine restart --ns $ns nginx-docs
64+ lttle machine restart --ns $ns typesense-search
65+ lttle machine restart --ns $ns typesense-scraper
66+ }
0 commit comments