mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-18 08:02:31 -05:00
Added AWS files to
- upgrade database - use credstash for secret overrides
This commit is contained in:
@@ -15,7 +15,7 @@ ma = Marshmallow()
|
||||
api_user = LocalProxy(lambda: _request_ctx_stack.top.api_user)
|
||||
|
||||
|
||||
def create_app(config_name):
|
||||
def create_app(config_name, config_overrides=None):
|
||||
application = Flask(__name__)
|
||||
|
||||
application.config['NOTIFY_API_ENVIRONMENT'] = config_name
|
||||
@@ -23,7 +23,7 @@ def create_app(config_name):
|
||||
|
||||
db.init_app(application)
|
||||
ma.init_app(application)
|
||||
init_app(application)
|
||||
init_app(application, config_overrides)
|
||||
logging.init_app(application)
|
||||
|
||||
from app.service.rest import service as service_blueprint
|
||||
@@ -41,11 +41,16 @@ def create_app(config_name):
|
||||
return application
|
||||
|
||||
|
||||
def init_app(app):
|
||||
def init_app(app, config_overrides):
|
||||
for key, value in app.config.items():
|
||||
if key in os.environ:
|
||||
app.config[key] = convert_to_boolean(os.environ[key])
|
||||
|
||||
if config_overrides:
|
||||
for key in app.config.keys():
|
||||
if key in config_overrides:
|
||||
app.config[key] = config_overrides[key]
|
||||
|
||||
@app.before_request
|
||||
def required_authentication():
|
||||
from app.authentication import auth
|
||||
|
||||
15
db.py
Normal file
15
db.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from flask.ext.script import Manager, Server
|
||||
from flask_migrate import Migrate, MigrateCommand
|
||||
from app import create_app, db
|
||||
from credstash import getAllSecrets
|
||||
|
||||
secrets = getAllSecrets(region="eu-west-1")
|
||||
|
||||
application = create_app('live', secrets)
|
||||
|
||||
manager = Manager(application)
|
||||
migrate = Migrate(application, db)
|
||||
manager.add_command('db', MigrateCommand)
|
||||
|
||||
if __name__ == '__main__':
|
||||
manager.run()
|
||||
@@ -11,6 +11,7 @@ marshmallow-sqlalchemy==0.8.0
|
||||
flask-marshmallow==0.6.2
|
||||
itsdangerous==0.24
|
||||
Flask-Bcrypt==0.6.2
|
||||
credstash==1.8.0
|
||||
|
||||
git+https://github.com/alphagov/notifications-python-client.git@0.1.5#egg=notifications-python-client==0.1.5
|
||||
|
||||
|
||||
@@ -1 +1,4 @@
|
||||
echo "Install dependencies"
|
||||
cd /home/ubuntu/notifications-api;
|
||||
pip3 install -r /home/ubuntu/notifications-api/requirements.txt
|
||||
python3 db.py db upgrade
|
||||
|
||||
Reference in New Issue
Block a user