From c91da348a081e72c1b3dbb5c80f530051403631a Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sun, 22 Dec 2019 11:36:48 +0700 Subject: [PATCH] Add deployment for the test site --- README.md | 10 ++++++---- fabfile.py | 18 ++++++++++++++++++ makefile | 20 ++++++++++---------- 3 files changed, 34 insertions(+), 14 deletions(-) create mode 100644 fabfile.py diff --git a/README.md b/README.md index c188903..53562a6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # voicegardens -> https://voicegardens.org +> main: https://voicegardens.org +> +> test: http://doesitsparkjoy.voicegardens.org ## @ Interwebz @@ -69,11 +71,11 @@ $ ssh voicegardens.org $ sudo -i # you have root access too ``` -Then it's possible to deploy the site with the following targets. +Then it's possible to release the site with the following targets. ```bash -$ make test-deploy # https://doesitsparkjoy.voicegardens.org -$ make prod-deploy # https://voicegardens.org +$ make doesitsparkjoy # https://doesitsparkjoy.voicegardens.org +$ make voicegardens # https://voicegardens.org ``` ### Layers of the Onion diff --git a/fabfile.py b/fabfile.py new file mode 100644 index 0000000..02f765a --- /dev/null +++ b/fabfile.py @@ -0,0 +1,18 @@ +"""Deployment with Fabric.""" + +from fabric import task + +@task +def doesitsparkjoy(c): + """Release doesitsparkjoy.voicegardens.org.""" + print('Releasing doesitsparkjoy.voicegardens.org ...') + with c.cd('/var/www/doesitsparkjoy.voicegardens.org'): + c.run('git pull origin master') + c.run('sudo supervisorctl restart doesitsparkjoy') + c.run('sudo systemctl restart nginx') + print('Released <3') + +@task +def voicegardens(c): + """Release voicegardens.org.""" + pass # TODO diff --git a/makefile b/makefile index 526e4ea..9a11970 100644 --- a/makefile +++ b/makefile @@ -1,20 +1,20 @@ -PROD_PORT := :9090 -PROD_WORKERS := 4 +SERVER := voicegardens.server +REMOTE_HOST := voicegardens.org ARCHIVE_DIR := ./voicegardens/archive default: dev-serve dev-serve: - @FLASK_ENV=development FLASK_APP=voicegardens.server flask run + @FLASK_ENV=development FLASK_APP=$(SERVER) flask run + +prod-serve: + @gunicorn --workers 1 --bind 9090 $(SERVER):app clear-archive: @rm -rf $(ARCHIVE_DIR)/* -prod-serve: - @gunicorn --workers $(PROD_WORKERS) --bind $(PROD_PORT) voicegardens.server:app - -test-deploy: - @echo 'TODO' +doesitsparkjoy: + @fab -H $(REMOTE_HOST) doesitsparkjoy -prod-deploy: - @echo 'TODO' +voicegardens: + @fab -H $(REMOTE_HOST) voicegardens