From 1660507889f901022f8a366f861909e564504c45 Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Tue, 11 Oct 2022 17:20:46 +0200 Subject: [PATCH] Add scripts for creating a new instance on heroku --- configure-instance.sh | 16 ++++++++++++++++ create-instance.sh | 10 ++++++++++ docs/new-heroku-instance.md | 8 ++++++++ new-instance.env.example | 7 +++++++ whitelabel.md | 4 ---- 5 files changed, 41 insertions(+), 4 deletions(-) create mode 100755 configure-instance.sh create mode 100755 create-instance.sh create mode 100644 docs/new-heroku-instance.md create mode 100644 new-instance.env.example delete mode 100644 whitelabel.md diff --git a/configure-instance.sh b/configure-instance.sh new file mode 100755 index 00000000..6c74d438 --- /dev/null +++ b/configure-instance.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +name=$1 +app=$name-prod +remote=$name +env=$name.env +rndm=$(echo $RANDOM | md5sum | head -c 32; echo) +config=$(heroku config -s -a my-kv-prod | grep -v '^HEROKU_' | grep -v 'VUE_APP_TITLE' | grep -v 'PAPERTRAIL' | grep -v 'DATABASE' | sed "s/'//g") +heroku git:remote --app $app --remote $remote +heroku config:set --app $app $config +heroku config:set --app $app APP_NAME=$app NEW_RELIC_APP_NAME=$app SECRET_KEY=$rndm `cat $env | sed "s/'//g"` +heroku config:unset --app $app BACKUP_AWS_ACCESS_KEY_ID BACKUP_AWS_SECRET_ACCESS_KEY BACKUP_S3_BUCKET_NAME PG_BACKUP_KEY SENTRY_DSN +heroku buildpacks:set --app $app heroku/nodejs +heroku buildpacks:add --app $app heroku/python +heroku buildpacks:add --app $app heroku-community/awscli +heroku buildpacks:add --app $app heroku-community/cli diff --git a/create-instance.sh b/create-instance.sh new file mode 100755 index 00000000..3155a0ca --- /dev/null +++ b/create-instance.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +name=$1 +app=$name-prod +heroku apps:create \ + --team skillbox \ + --region eu \ + --stack heroku-20 \ + --addons heroku-postgresql:hobby-basic,papertrail:choklad,scheduler:standard \ + $app diff --git a/docs/new-heroku-instance.md b/docs/new-heroku-instance.md new file mode 100644 index 00000000..5e12fd61 --- /dev/null +++ b/docs/new-heroku-instance.md @@ -0,0 +1,8 @@ +## Steps for new Instance + +- define an app name, e.g. mydetailhandel-efz +- create an .env file for this app with the name `$name.env` +- `./create-instance.sh ` +- `./configure-instance.sh ` +- heroku run --app $name-prod python server/manage.py dummy_data +- heroku run --app $name-prod python server/manage.py createsuperuser diff --git a/new-instance.env.example b/new-instance.env.example new file mode 100644 index 00000000..b2a84d2e --- /dev/null +++ b/new-instance.env.example @@ -0,0 +1,7 @@ +VUE_APP_TITLE='Title' +OAUTH_CLIENT_ID='ID' +OAUTH_CLIENT_SECRET='SECRET' +OAUTH_LOCAL_REDIRECT_URI='https://some-app.herokuapp.com/api/oauth/callback/' +AWS_ACCESS_KEY_ID='AWSID' +AWS_SECRET_ACCESS_KEY='AWSSECRET' +AWS_STORAGE_BUCKET_NAME='BUCKET' diff --git a/whitelabel.md b/whitelabel.md deleted file mode 100644 index 8c1a910c..00000000 --- a/whitelabel.md +++ /dev/null @@ -1,4 +0,0 @@ -## Steps for new Instance - -- `python server/manage.py create_superuser # guru` -- `python server/manage.py create_teacher mia teacher mia.teacher@getnada.com`