Commit bee2cf2f authored by Haakon Gunleiksrud's avatar Haakon Gunleiksrud
Browse files

Devops/setup live demo

parent 5b571503
......@@ -22,4 +22,4 @@ staging:
- dpl --provider=heroku --app=secfit-frontend-v22 --api-key=$HEROKU_STAGING_API_KEY
- dpl --provider=heroku --app=secfit-backend-v22 --api-key=$HEROKU_STAGING_API_KEY
only:
- master
- master
\ No newline at end of file
......@@ -8,6 +8,8 @@ SecFit (Secure Fitness) is a hybrid mobile application for fitness logging.
Docker
Python 3.8.10
Git
Windows hosts must use Education or more advanced versions to run Docker \
......@@ -137,18 +139,22 @@ Continuous integration will build the code pushed to master and push it to your
3. Select buildpacks for the two apps. The backend uses Python while the frontend uses nodejs.
* Heroku > Settings > Buildpacks > Add buildpack
* Both applications need the buildpack https://github.com/heroku/heroku-buildpack-multi-procfile.git too.
3. Set the project in the .gitlab-cs.yml file by replacing `<Your-herokuproject-name>` with the name of the Heroku app you created
4. Set the two projects in the .gitlab-cs.yml file by replacing `<Your-herokuproject-name>` with the name of the Heroku apps you created. Commit and push your change.
`- dpl --provider=heroku --app=<Your-herokuproject-name> --api-key=$HEROKU_STAGING_API_KEY`
5. Set varibles at GitLab
* settings > ci > Environment Variables
* `HEROKU_STAGING_API_KEY` = heroku > Account Settings > API Key
5. Set/Add varibles at GitLab
* GitLab > settings > ci > Variables > Expand
* Key = `HEROKU_STAGING_API_KEY`
* Value = Your API Key from Heroku (Heroku > Account Settings > API Key > Reveal)
* Type = Variable, Environment scope = All(default)
* Protect should not be enabled and Mask should be enabled
6. Add heroku database for the backend
* Resources > Add ons > search for postgres > add "Heroku Postgres"
7. Set variables for the backend on Heroku. Settings > Config vars > Reveal vars
* `DATABASE_URL` = Should be set by default. If not here is where you can find it: Resources > postgress > settings > view credentials > URI
* Heroku > Resources > Add ons > search for `postgres` > add "Heroku Postgres"
* Choose the free plan.
7. Set variables for the backend on Heroku. Heroku > Settings > Config vars > Reveal vars
* `DATABASE_URL` = Should be set by default. If not here is where you can find it: Heroku > Resources > postgress > settings > view credentials > URI
* `IS_HEROKU` = `IS_HEROKU`
* `PROCFILE` = `backend/secfit/Procfile`
8. Set variables for the frontend on heroku. Settings > Config vars > Reveal vars. Insert the URL for your backend app.
* `PROCFILE` = `Procfile`
8. Set variables for the frontend on heroku. Heroku > Settings > Config vars > Reveal vars. Insert the URL for your backend app and the path to your Procfile. (Example: `https://secfit-group01-v22-backend.herokuapp.com`)
* `BACKEND_HOST` = `https://<SECFIT_BACKEND>.herokuapp.com`
* `PROCFILE` = `frontend/Procfile`
9. Push the repository to both of the heroku applications
......@@ -156,19 +162,14 @@ Continuous integration will build the code pushed to master and push it to your
* Make sure you install the heroku CLI https://devcenter.heroku.com/articles/heroku-cli
* Make sure you log in to the heroku CLI ($ heroku login)
* Make sure you create a remote for the frontend and backend apps (Example: heroku git:remote -a secfit-group01-v22-frontend)
* Push your code to both apps ($ git push https://git.heroku.com/<YOUR-HEROKU-APP>.git)
* Push your code to both apps (Your URLs can also be found on the settings page on your Heroku apps)
* Example: $ git push https://git.heroku.com/secfit-group01-v22-frontend.git master
* Make sure you use `master` and not `main` as your target branch
10. Setup a dyno for you backend
11. On GitLab go to CI / CD in the repository menu and select `Run Pipeline` if it has not already started. When both stages complete the app should be available on heroku. The log should state that the app was deployed.
12. Setup the applications database.
* Log in to the Heroku CLI by entering `heroku login` if you have not alreaddy done this. This opens a webbrowser and you accept the login request.
10. On GitLab go to CI / CD in the repository menu and select `Run Pipeline` if it has not already started. When both stages complete the app should be available on heroku. The log should state that the app was deployed.
11. Setup the applications database.
* Log in to the Heroku CLI by entering `heroku login` if you have not already done this. This opens a webbrowser and you accept the login request.
* Migrate database by entering
`heroku run python backend/secfit/manage.py migrate -a <heroku-app-name>`. `Heroku run` will run the folowing command on your heroku instance. Remember to replace `<heroku-app-name>` with your app name
* and create an admin account by running
`heroku run python backend/secfit/manage.py migrate -a <heroku-app-name>`. `Heroku run` will run the folowing command on your heroku instance. Remember to replace `<heroku-app-name>` with your backend app name
* and create an admin account for the backend by running
`heroku run python backend/secfit/manage.py createsuperuser -a <heroku-app-name>`.
* seed database `heroku run python backend/secfit/manage.py loaddata seed.json -a <heroku-app-name>`
12. On the frontend app, add a config variable for `BACKEND_HOST` = `BACKEND_HOST`
You will also need the heroku multi-procfile buildpack: https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-multi-procfile.
In general, for this application to work (beyond locally), you will need to set the BACKEND_HOST to the URL of the REST API backend.
* seed database `heroku run python backend/secfit/manage.py loaddata backend/secfit/seed.json -a <heroku-app-name>`
\ No newline at end of file
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment