-
Notifications
You must be signed in to change notification settings - Fork 1
/
heroku_1_deploy.sh
91 lines (69 loc) · 2.41 KB
/
heroku_1_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
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
#!/bin/bash
source heroku_0_config.sh
if [[ "$*" == *"--debug"* ]]; then
echo "Running with DEBUG mode (echo all executing bash,..?)"
set -x # enable debug mode
else
echo "Use --debug for running with DEBUG mode"
fi
echo "The first argument is: $1"
echo "The second argument is: $2"
echo "The second argument is: $3"
export API_KEY=$1
export creds_gdrive_id=$2
PYTHON="python-3.9.16"
echo Starting app $APP_NAME
##? 1st login
#todo: add?
#heroku auth
#heroku login
# create a new Heroku app
#todo: add:
#heroku drop $APP_NAME #: › Warning: drop is not a heroku command.
#Did you mean stop? [y/n]:
# › Error: Run heroku help for a list of available commands.
heroku create $APP_NAME
# set the Python buildpack
heroku buildpacks:set heroku/python
#fixme:
#`Creating heroku-postgresql:hobby-dev on ⬢ gsheet-to-xml7... !
# ▸ Couldn't find either the add-on service or the add-on plan of
# ▸ "heroku-postgresql:hobby-dev".
## add postgres add-on to the app
#heroku addons:create heroku-postgresql:hobby-dev
##`? get the URL of the Postgres database
#DATABASE_URL=$(heroku config:get DATABASE_URL)
# create a `Procfile` in the root of your project with the following contents:
# web: uvicorn main:app --host 0.0.0.0 --port $PORT --workers 1
echo "web: uvicorn main:app --host 0.0.0.0 --port \$PORT --workers 1" > Procfile
# create a new file `runtime.txt` in the root of your project with the following contents:
echo # echo "python-3.11.2" > runtime.txt
echo $PYTHON > runtime.txt
## create a new file `requirements.txt` in the root of your project with the following contents:
# Using exising after dedup lines!
#python util --dedup_lines requirements.txt
#echo "fastapi" >> requirements.txt
#echo "uvicorn" >> requirements.txt
#echo "sqlalchemy" >> requirements.txt
#echo "# app <$APP_NAME> was used!" >> requirements.txt
echo # add all files to Git and push to Heroku
git init
git add .
#todo: add
#!wr git diff --cached
git commit -m "Initial commit"
heroku git:remote -a $APP_NAME
git push heroku master
git push heroku main
# Check if --run argument is present
if [[ "$*" == *"--run"* ]]; then
echo "Running the deployed solution:.."
# do something when --run is present
sh heroku_2_run.sh
else
echo "Not running the deployed solution."
# do something when --run is not present
fi
echo # View logf
heroku logs --tail
set +x # disable debug mode