From aa6f7c52b45f1ddff02e622d7c9870e81d18c9ce Mon Sep 17 00:00:00 2001 From: Vincent Agnano Date: Mon, 9 Oct 2017 09:42:36 -0400 Subject: [PATCH 1/2] added deployment task --- Makefile | 10 ++++++++++ readme.md | 9 +++++++++ 2 files changed, 19 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..250cf54 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +goto_src=cd ~/src && source ../venv/bin/activate + +help: + @echo "Make tasks for deployment. Checkout the makefile content." + +deploy: + @echo "Fetching master branch and updating sources." + ssh cafebabel "${goto_src} && git fetch origin master && git checkout master && git reset --hard FETCH_HEAD" + ssh cafebabel "${goto_src} && pip install -r requirements.txt" + ssh cafebabel "${goto_src} && python app.py 0.0.0.0:5000 &" diff --git a/readme.md b/readme.md index 2a61237..a3f5d8b 100644 --- a/readme.md +++ b/readme.md @@ -35,8 +35,17 @@ re-initializing the database. flask run ``` + ## Running a dummy mail server ``` sudo python -m smtpd -n -c DebuggingServer localhost:25 ``` + + +## Deploying + +In order to deploy to the staging server, you should have an SSH access +to the server with the _cafebabel_ user callable via the command `ssh cafebabel`. + +With that working, you may deploy using the command `make deploy`. From 46f9c2a03c8d2a4fc404633682c933e1dde67540 Mon Sep 17 00:00:00 2001 From: Vincent Agnano Date: Mon, 9 Oct 2017 21:33:47 -0400 Subject: [PATCH 2/2] added installation make task --- Makefile | 11 +++++++++-- cafebabel/core/__init__.py | 9 +++++++-- readme.md | 7 +++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 250cf54..4c76851 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,17 @@ -goto_src=cd ~/src && source ../venv/bin/activate +goto_src=cd ~/src && source ~/venv/bin/activate help: @echo "Make tasks for deployment. Checkout the makefile content." deploy: - @echo "Fetching master branch and updating sources." + @echo "> Fetching master branch and updating sources." ssh cafebabel "${goto_src} && git fetch origin master && git checkout master && git reset --hard FETCH_HEAD" ssh cafebabel "${goto_src} && pip install -r requirements.txt" ssh cafebabel "${goto_src} && python app.py 0.0.0.0:5000 &" + +install: + @echo "> Installing sources, dependencies and database." + ssh cafebabel "git clone https://github.com/cafebabel/cafebabel.com.git ~/src" + ssh cafebabel "python3.6 -m venv ~/venv" + ssh cafebabel "${goto_src} && pip install -r requirements.txt" + ssh cafebabel "${goto_src} && FLASK_APP=app.py flask initdb" diff --git a/cafebabel/core/__init__.py b/cafebabel/core/__init__.py index 585ce1d..4842f02 100644 --- a/cafebabel/core/__init__.py +++ b/cafebabel/core/__init__.py @@ -1,7 +1,6 @@ from pathlib import Path from flask import Flask -from flask_debugtoolbar import DebugToolbarExtension from flask_peewee.db import Database from flask_mail import Mail @@ -13,4 +12,10 @@ db = Database(app) mail = Mail(app) -toolbar = DebugToolbarExtension(app) + +# Dev specific packages +try: + from flask_debugtoolbar import DebugToolbarExtension + toolbar = DebugToolbarExtension(app) +except ModuleNotFoundError: + pass diff --git a/readme.md b/readme.md index a3f5d8b..dcbc150 100644 --- a/readme.md +++ b/readme.md @@ -43,9 +43,12 @@ sudo python -m smtpd -n -c DebuggingServer localhost:25 ``` -## Deploying +## Production installation In order to deploy to the staging server, you should have an SSH access to the server with the _cafebabel_ user callable via the command `ssh cafebabel`. -With that working, you may deploy using the command `make deploy`. +Your server must have python3.6 installed. + +Installation can be processed with `make install`. +Deploying will run through `make deploy`.