commit
477d1216ad
|
@ -37,7 +37,7 @@ deploy:
|
||||||
skip_cleanup: true
|
skip_cleanup: true
|
||||||
on:
|
on:
|
||||||
all_branches: true
|
all_branches: true
|
||||||
condition: $TRAVIS_BRANCH =~ ^(testing|staging|master)$
|
condition: $TRAVIS_BRANCH =~ ^(dev|testing|demo|training|staging|master|rrt\/.*)$
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email:
|
email:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
from os import environ
|
from os import environ
|
||||||
|
|
||||||
basedir = os.path.abspath(os.path.dirname(__file__))
|
basedir = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
@ -6,7 +7,7 @@ basedir = os.path.abspath(os.path.dirname(__file__))
|
||||||
JSON_SORT_KEYS = False # CRITICAL. Do not sort the data when returning values to the front end.
|
JSON_SORT_KEYS = False # CRITICAL. Do not sort the data when returning values to the front end.
|
||||||
|
|
||||||
NAME = "CR Connect Workflow"
|
NAME = "CR Connect Workflow"
|
||||||
CORS_ENABLED = False
|
CORS_ALLOW_ORIGINS = re.split(r',\s*', environ.get('CORS_ALLOW_ORIGINS', default="localhost:4200, localhost:5002"))
|
||||||
DEVELOPMENT = environ.get('DEVELOPMENT', default="true") == "true"
|
DEVELOPMENT = environ.get('DEVELOPMENT', default="true") == "true"
|
||||||
TESTING = environ.get('TESTING', default="false") == "true"
|
TESTING = environ.get('TESTING', default="false") == "true"
|
||||||
PRODUCTION = (environ.get('PRODUCTION', default="false") == "true") or (not DEVELOPMENT and not TESTING)
|
PRODUCTION = (environ.get('PRODUCTION', default="false") == "true") or (not DEVELOPMENT and not TESTING)
|
||||||
|
@ -26,6 +27,7 @@ FRONTEND_AUTH_CALLBACK = environ.get('FRONTEND_AUTH_CALLBACK', default="http://l
|
||||||
SWAGGER_AUTH_KEY = environ.get('SWAGGER_AUTH_KEY', default="SWAGGER")
|
SWAGGER_AUTH_KEY = environ.get('SWAGGER_AUTH_KEY', default="SWAGGER")
|
||||||
|
|
||||||
#: Default attribute map for single signon.
|
#: Default attribute map for single signon.
|
||||||
|
SSO_LOGIN_URL = '/login'
|
||||||
SSO_ATTRIBUTE_MAP = {
|
SSO_ATTRIBUTE_MAP = {
|
||||||
'eppn': (False, 'eppn'), # dhf8r@virginia.edu
|
'eppn': (False, 'eppn'), # dhf8r@virginia.edu
|
||||||
'uid': (True, 'uid'), # dhf8r
|
'uid': (True, 'uid'), # dhf8r
|
||||||
|
@ -48,7 +50,10 @@ LDAP_URL = environ.get('LDAP_URL', default="ldap.virginia.edu")
|
||||||
LDAP_TIMEOUT_SEC = environ.get('LDAP_TIMEOUT_SEC', default=3)
|
LDAP_TIMEOUT_SEC = environ.get('LDAP_TIMEOUT_SEC', default=3)
|
||||||
print('=== USING DEFAULT CONFIG: ===')
|
print('=== USING DEFAULT CONFIG: ===')
|
||||||
print('DB_HOST = ', DB_HOST)
|
print('DB_HOST = ', DB_HOST)
|
||||||
|
print('CORS_ALLOW_ORIGINS = ', CORS_ALLOW_ORIGINS)
|
||||||
print('DEVELOPMENT = ', DEVELOPMENT)
|
print('DEVELOPMENT = ', DEVELOPMENT)
|
||||||
print('TESTING = ', TESTING)
|
print('TESTING = ', TESTING)
|
||||||
print('PRODUCTION = ', PRODUCTION)
|
print('PRODUCTION = ', PRODUCTION)
|
||||||
print('PB_BASE_URL = ', PB_BASE_URL)
|
print('PB_BASE_URL = ', PB_BASE_URL)
|
||||||
|
print('LDAP_URL = ', LDAP_URL)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ import os
|
||||||
basedir = os.path.abspath(os.path.dirname(__file__))
|
basedir = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
NAME = "CR Connect Workflow"
|
NAME = "CR Connect Workflow"
|
||||||
CORS_ENABLED = False
|
|
||||||
DEVELOPMENT = True
|
DEVELOPMENT = True
|
||||||
TESTING = True
|
TESTING = True
|
||||||
SQLALCHEMY_DATABASE_URI = "postgresql://crc_user:crc_pass@localhost:5432/crc_test"
|
SQLALCHEMY_DATABASE_URI = "postgresql://crc_user:crc_pass@localhost:5432/crc_test"
|
||||||
|
|
|
@ -2,7 +2,6 @@ import os
|
||||||
basedir = os.path.abspath(os.path.dirname(__file__))
|
basedir = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
NAME = "CR Connect Workflow"
|
NAME = "CR Connect Workflow"
|
||||||
CORS_ENABLED = False
|
|
||||||
DEVELOPMENT = True
|
DEVELOPMENT = True
|
||||||
TESTING = True
|
TESTING = True
|
||||||
SQLALCHEMY_DATABASE_URI = "postgresql://postgres:@localhost:5432/crc_test"
|
SQLALCHEMY_DATABASE_URI = "postgresql://postgres:@localhost:5432/crc_test"
|
||||||
|
|
|
@ -4,9 +4,10 @@ import os
|
||||||
import connexion
|
import connexion
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
from flask_marshmallow import Marshmallow
|
from flask_marshmallow import Marshmallow
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
|
||||||
from flask_migrate import Migrate
|
from flask_migrate import Migrate
|
||||||
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
from flask_sso import SSO
|
from flask_sso import SSO
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
connexion_app = connexion.FlaskApp(__name__)
|
connexion_app = connexion.FlaskApp(__name__)
|
||||||
|
@ -36,7 +37,12 @@ from crc import models
|
||||||
from crc import api
|
from crc import api
|
||||||
|
|
||||||
connexion_app.add_api('api.yml')
|
connexion_app.add_api('api.yml')
|
||||||
|
|
||||||
|
# Convert list of allowed origins to list of regexes
|
||||||
|
origins_re = [r"^https?:\/\/%s(.*)" % o.replace('.', '\.') for o in app.config['CORS_ALLOW_ORIGINS']]
|
||||||
|
logging.getLogger('flask_cors').level = logging.DEBUG
|
||||||
cors = CORS(connexion_app.app)
|
cors = CORS(connexion_app.app)
|
||||||
|
# cors = CORS(connexion_app.app, origins=origins_re)
|
||||||
|
|
||||||
|
|
||||||
@app.cli.command()
|
@app.cli.command()
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import json
|
||||||
|
|
||||||
import connexion
|
import connexion
|
||||||
from flask import redirect, g
|
from flask import redirect, g
|
||||||
|
|
||||||
|
@ -33,6 +35,7 @@ def get_current_user():
|
||||||
|
|
||||||
@sso.login_handler
|
@sso.login_handler
|
||||||
def sso_login(user_info):
|
def sso_login(user_info):
|
||||||
|
app.logger.info("Login from Shibboleth happening. " + json.dump(user_info))
|
||||||
# TODO: Get redirect URL from Shibboleth request header
|
# TODO: Get redirect URL from Shibboleth request header
|
||||||
_handle_login(user_info)
|
_handle_login(user_info)
|
||||||
|
|
||||||
|
|
44
deploy.sh
44
deploy.sh
|
@ -1,22 +1,44 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
function branch_to_tag () {
|
||||||
|
if [ "$1" == "latest" ]; then echo "production"; else echo "$1" ; fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function branch_to_deploy_group() {
|
||||||
|
if [[ $1 =~ ^(rrt\/.*)$ ]]; then echo "rrt"; else echo "crconnect" ; fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function branch_to_deploy_stage () {
|
||||||
|
if [ "$1" == "master" ]; then echo "production"; else echo "$1" ; fi
|
||||||
|
}
|
||||||
|
|
||||||
|
REPO="sartography/cr-connect-workflow"
|
||||||
|
TAG=$(branch_to_tag "$TRAVIS_BRANCH")
|
||||||
|
|
||||||
|
DEPLOY_APP="backend"
|
||||||
|
DEPLOY_GROUP=$(branch_to_deploy_group "$TRAVIS_BRANCH")
|
||||||
|
DEPLOY_STAGE=$(branch_to_deploy_stage "$TRAVIS_BRANCH")
|
||||||
|
|
||||||
|
if [ "$DEPLOY_GROUP" == "rrt" ]; then
|
||||||
|
IFS='/' read -ra ARR <<< "$TRAVIS_BRANCH" # Split branch on '/' character
|
||||||
|
TAG=$(branch_to_tag "rrt_${ARR[1]}")
|
||||||
|
DEPLOY_STAGE=$(branch_to_deploy_stage "${ARR[1]}")
|
||||||
|
fi
|
||||||
|
|
||||||
|
DEPLOY_PATH="$DEPLOY_GROUP/$DEPLOY_STAGE/$DEPLOY_APP"
|
||||||
|
echo "REPO = $REPO"
|
||||||
|
echo "TAG = $TAG"
|
||||||
|
echo "DEPLOY_PATH = $DEPLOY_PATH"
|
||||||
|
|
||||||
# Build and push Docker image to Docker Hub
|
# Build and push Docker image to Docker Hub
|
||||||
echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin || exit 1
|
echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin || exit 1
|
||||||
REPO="sartography/cr-connect-workflow"
|
docker build -f Dockerfile -t "$REPO:$TAG" . || exit 1
|
||||||
TAG=$(if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo "$TRAVIS_BRANCH" ; fi)
|
|
||||||
COMMIT=${TRAVIS_COMMIT::8}
|
|
||||||
|
|
||||||
docker build -f Dockerfile -t "$REPO:$COMMIT" . || exit 1
|
|
||||||
docker tag "$REPO:$COMMIT" "$REPO:$TAG" || exit 1
|
|
||||||
docker tag "$REPO:$COMMIT" "$REPO:travis-$TRAVIS_BUILD_NUMBER" || exit 1
|
|
||||||
docker push "$REPO" || exit 1
|
docker push "$REPO" || exit 1
|
||||||
|
|
||||||
# Wait for Docker Hub
|
# Wait for Docker Hub
|
||||||
echo "Publishing to Docker Hub..."
|
echo "Publishing to Docker Hub..."
|
||||||
sleep 30
|
sleep 30
|
||||||
|
|
||||||
# Notify DC/OS that Docker image has been updated
|
# Notify UVA DCOS that Docker image has been updated
|
||||||
echo "Refreshing DC/OS..."
|
echo "Refreshing DC/OS..."
|
||||||
STAGE=$(if [ "$TRAVIS_BRANCH" == "master" ]; then echo "production"; else echo "$TRAVIS_BRANCH" ; fi)
|
aws sqs send-message --region "$AWS_DEFAULT_REGION" --queue-url "$AWS_SQS_URL" --message-body "$DEPLOY_PATH" || exit 1
|
||||||
echo "STAGE = $STAGE"
|
|
||||||
aws sqs send-message --region "$AWS_DEFAULT_REGION" --queue-url "$AWS_SQS_URL" --message-body "crconnect/$STAGE/backend" || exit 1
|
|
||||||
|
|
Loading…
Reference in New Issue