Merge pull request #114 from sartography/frontend/use-api-subpath
frontend: use /api subpath instead of subdomain
This commit is contained in:
commit
4bf191af31
2
.flake8
2
.flake8
|
@ -32,7 +32,7 @@ per-file-ignores =
|
||||||
# the exclude=./migrations option doesn't seem to work with pre-commit
|
# the exclude=./migrations option doesn't seem to work with pre-commit
|
||||||
# migrations are autogenerated from "flask db migration" so ignore them
|
# migrations are autogenerated from "flask db migration" so ignore them
|
||||||
spiffworkflow-backend/migrations/*:D
|
spiffworkflow-backend/migrations/*:D
|
||||||
spiffworkflow-backend/src/spiffworkflow_backend/config/testing.py:S105
|
spiffworkflow-backend/src/spiffworkflow_backend/config/unit_testing.py:S105
|
||||||
spiffworkflow-backend/src/spiffworkflow_backend/load_database_models.py:F401
|
spiffworkflow-backend/src/spiffworkflow_backend/load_database_models.py:F401
|
||||||
|
|
||||||
# this file overwrites methods from the logging library so we can't change them
|
# this file overwrites methods from the logging library so we can't change them
|
||||||
|
|
|
@ -32,7 +32,7 @@ per-file-ignores =
|
||||||
# the exclude=./migrations option doesn't seem to work with pre-commit
|
# the exclude=./migrations option doesn't seem to work with pre-commit
|
||||||
# migrations are autogenerated from "flask db migration" so ignore them
|
# migrations are autogenerated from "flask db migration" so ignore them
|
||||||
migrations/*:D
|
migrations/*:D
|
||||||
src/spiffworkflow_backend/config/testing.py:S105
|
src/spiffworkflow_backend/config/unit_testing.py:S105
|
||||||
src/spiffworkflow_backend/load_database_models.py:F401
|
src/spiffworkflow_backend/load_database_models.py:F401
|
||||||
|
|
||||||
# this file overwrites methods from the logging library so we can't change them
|
# this file overwrites methods from the logging library so we can't change them
|
||||||
|
|
|
@ -25,6 +25,14 @@ if [[ "${SPIFFWORKFLOW_BACKEND_UPGRADE_DB:-}" == "true" ]]; then
|
||||||
poetry run flask db upgrade
|
poetry run flask db upgrade
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${GUNICORN_LOG_LEVEL:-}" ]]; then
|
||||||
|
GUNICORN_LOG_LEVEL=debug
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${GUNICORN_TIMEOUT_SECONDS:-}" ]]; then
|
||||||
|
GUNICORN_TIMEOUT_SECONDS=90
|
||||||
|
fi
|
||||||
|
|
||||||
port="${SPIFFWORKFLOW_BACKEND_PORT:-}"
|
port="${SPIFFWORKFLOW_BACKEND_PORT:-}"
|
||||||
if [[ -z "$port" ]]; then
|
if [[ -z "$port" ]]; then
|
||||||
port=7000
|
port=7000
|
||||||
|
@ -53,4 +61,11 @@ git config --global --add safe.directory "${BPMN_SPEC_ABSOLUTE_DIR}"
|
||||||
|
|
||||||
export IS_GUNICORN="true"
|
export IS_GUNICORN="true"
|
||||||
# THIS MUST BE THE LAST COMMAND!
|
# THIS MUST BE THE LAST COMMAND!
|
||||||
exec poetry run gunicorn ${additional_args} --bind "0.0.0.0:$port" --workers="$workers" --limit-request-line 8192 --timeout 90 --capture-output --access-logfile '-' --log-level debug wsgi:app
|
exec poetry run gunicorn ${additional_args} \
|
||||||
|
--bind "0.0.0.0:$port" \
|
||||||
|
--workers="$workers" \
|
||||||
|
--limit-request-line 8192 \
|
||||||
|
--timeout "$GUNICORN_TIMEOUT_SECONDS" \
|
||||||
|
--capture-output \
|
||||||
|
--access-logfile '-' \
|
||||||
|
--log-level "$GUNICORN_LOG_LEVEL" wsgi:app
|
||||||
|
|
|
@ -8,7 +8,7 @@ from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
||||||
|
|
||||||
def main(process_instance_id: str):
|
def main(process_instance_id: str):
|
||||||
"""Main."""
|
"""Main."""
|
||||||
os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "development"
|
os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "local_development"
|
||||||
if os.environ.get("BPMN_SPEC_ABSOLUTE_DIR") is None:
|
if os.environ.get("BPMN_SPEC_ABSOLUTE_DIR") is None:
|
||||||
os.environ["BPMN_SPEC_ABSOLUTE_DIR"] = "hey"
|
os.environ["BPMN_SPEC_ABSOLUTE_DIR"] = "hey"
|
||||||
flask_env_key = "FLASK_SESSION_SECRET_KEY"
|
flask_env_key = "FLASK_SESSION_SECRET_KEY"
|
||||||
|
|
|
@ -35,8 +35,8 @@ if [[ "${1:-}" == "clean" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f ./src/instance/*.sqlite3
|
rm -f ./src/instance/*.sqlite3
|
||||||
mysql -uroot -e "DROP DATABASE IF EXISTS spiffworkflow_backend_development"
|
mysql -uroot -e "DROP DATABASE IF EXISTS spiffworkflow_backend_local_development"
|
||||||
mysql -uroot -e "DROP DATABASE IF EXISTS spiffworkflow_backend_testing"
|
mysql -uroot -e "DROP DATABASE IF EXISTS spiffworkflow_backend_unit_testing"
|
||||||
|
|
||||||
# TODO: check to see if the db already exists and we can connect to it. also actually clean it up.
|
# TODO: check to see if the db already exists and we can connect to it. also actually clean it up.
|
||||||
# start postgres in background with one db
|
# start postgres in background with one db
|
||||||
|
@ -45,23 +45,23 @@ if [[ "${1:-}" == "clean" ]]; then
|
||||||
docker run --name postgres-spiff -p 5432:5432 -e POSTGRES_PASSWORD=spiffworkflow_backend -e POSTGRES_USER=spiffworkflow_backend -e POSTGRES_DB=spiffworkflow_backend_testing -d postgres
|
docker run --name postgres-spiff -p 5432:5432 -e POSTGRES_PASSWORD=spiffworkflow_backend -e POSTGRES_USER=spiffworkflow_backend -e POSTGRES_DB=spiffworkflow_backend_testing -d postgres
|
||||||
sleep 4 # classy
|
sleep 4 # classy
|
||||||
fi
|
fi
|
||||||
if ! docker exec -it postgres-spiff psql -U spiffworkflow_backend spiffworkflow_backend_development -c "select 1"; then
|
if ! docker exec -it postgres-spiff psql -U spiffworkflow_backend spiffworkflow_backend_local_development -c "select 1"; then
|
||||||
# create other db. spiffworkflow_backend_testing came with the docker run.
|
# create other db. spiffworkflow_backend_testing came with the docker run.
|
||||||
docker exec -it postgres-spiff psql -U spiffworkflow_backend spiffworkflow_backend_testing -c "create database spiffworkflow_backend_development;"
|
docker exec -it postgres-spiff psql -U spiffworkflow_backend spiffworkflow_backend_testing -c "create database spiffworkflow_backend_local_development;"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
tasks="$tasks upgrade"
|
tasks="$tasks upgrade"
|
||||||
|
|
||||||
mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_development"
|
mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_local_development"
|
||||||
mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_testing"
|
mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_unit_testing"
|
||||||
|
|
||||||
for task in $tasks; do
|
for task in $tasks; do
|
||||||
SPIFFWORKFLOW_BACKEND_ENV=development FLASK_APP=src/spiffworkflow_backend poetry run flask db "$task"
|
SPIFFWORKFLOW_BACKEND_ENV=local_development FLASK_APP=src/spiffworkflow_backend poetry run flask db "$task"
|
||||||
done
|
done
|
||||||
|
|
||||||
SPIFFWORKFLOW_BACKEND_ENV=testing FLASK_APP=src/spiffworkflow_backend poetry run flask db upgrade
|
SPIFFWORKFLOW_BACKEND_ENV=unit_testing FLASK_APP=src/spiffworkflow_backend poetry run flask db upgrade
|
||||||
if [[ -n "${SPIFFWORKFLOW_BACKEND_ENV:-}" ]] && ! grep -Eq '^(development|testing)$' <<< "$SPIFFWORKFLOW_BACKEND_ENV"; then
|
if [[ -n "${SPIFFWORKFLOW_BACKEND_ENV:-}" ]] && ! grep -Eq '^(local_development|unit_testing)$' <<< "$SPIFFWORKFLOW_BACKEND_ENV"; then
|
||||||
mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_$SPIFFWORKFLOW_BACKEND_ENV"
|
mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_$SPIFFWORKFLOW_BACKEND_ENV"
|
||||||
FLASK_APP=src/spiffworkflow_backend poetry run flask db upgrade
|
FLASK_APP=src/spiffworkflow_backend poetry run flask db upgrade
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -14,7 +14,7 @@ if [[ "$arg" == "acceptance" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "${SPIFFWORKFLOW_BACKEND_ENV:-}" ]]; then
|
if [[ -z "${SPIFFWORKFLOW_BACKEND_ENV:-}" ]]; then
|
||||||
export SPIFFWORKFLOW_BACKEND_ENV=development
|
export SPIFFWORKFLOW_BACKEND_ENV=local_development
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BPMN_SPEC_ABSOLUTE_DIR=$(./bin/find_sample_process_models)
|
BPMN_SPEC_ABSOLUTE_DIR=$(./bin/find_sample_process_models)
|
||||||
|
|
|
@ -10,7 +10,7 @@ from spiffworkflow_backend.services.secret_service import SecretService
|
||||||
|
|
||||||
def main(env_file: str):
|
def main(env_file: str):
|
||||||
"""Main."""
|
"""Main."""
|
||||||
os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "development"
|
os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "local_development"
|
||||||
if os.environ.get("BPMN_SPEC_ABSOLUTE_DIR") is None:
|
if os.environ.get("BPMN_SPEC_ABSOLUTE_DIR") is None:
|
||||||
os.environ["BPMN_SPEC_ABSOLUTE_DIR"] = "hey"
|
os.environ["BPMN_SPEC_ABSOLUTE_DIR"] = "hey"
|
||||||
flask_env_key = "FLASK_SESSION_SECRET_KEY"
|
flask_env_key = "FLASK_SESSION_SECRET_KEY"
|
||||||
|
|
|
@ -37,7 +37,7 @@ from spiffworkflow_backend import create_app # noqa: E402
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def app() -> Flask:
|
def app() -> Flask:
|
||||||
"""App."""
|
"""App."""
|
||||||
os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "testing"
|
os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "unit_testing"
|
||||||
os.environ["FLASK_SESSION_SECRET_KEY"] = "super_secret_key"
|
os.environ["FLASK_SESSION_SECRET_KEY"] = "super_secret_key"
|
||||||
app = create_app()
|
app = create_app()
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ services:
|
||||||
context: .
|
context: .
|
||||||
environment:
|
environment:
|
||||||
- APPLICATION_ROOT=/
|
- APPLICATION_ROOT=/
|
||||||
- SPIFFWORKFLOW_BACKEND_ENV=${SPIFFWORKFLOW_BACKEND_ENV:-development}
|
- SPIFFWORKFLOW_BACKEND_ENV=${SPIFFWORKFLOW_BACKEND_ENV:-local_development}
|
||||||
- FLASK_DEBUG=0
|
- FLASK_DEBUG=0
|
||||||
- FLASK_SESSION_SECRET_KEY=${FLASK_SESSION_SECRET_KEY:-super_secret_key}
|
- FLASK_SESSION_SECRET_KEY=${FLASK_SESSION_SECRET_KEY:-super_secret_key}
|
||||||
- OPEN_ID_SERVER_URL=${OPEN_ID_SERVER_URL:-http://localhost:7002/realms/spiffworkflow}
|
- OPEN_ID_SERVER_URL=${OPEN_ID_SERVER_URL:-http://localhost:7002/realms/spiffworkflow}
|
||||||
|
|
|
@ -42,7 +42,7 @@ def setup_database(session: Session) -> None:
|
||||||
flask_env_key = "FLASK_SESSION_SECRET_KEY"
|
flask_env_key = "FLASK_SESSION_SECRET_KEY"
|
||||||
session.env[flask_env_key] = "super_secret_key"
|
session.env[flask_env_key] = "super_secret_key"
|
||||||
session.env["FLASK_APP"] = "src/spiffworkflow_backend"
|
session.env["FLASK_APP"] = "src/spiffworkflow_backend"
|
||||||
session.env["SPIFFWORKFLOW_BACKEND_ENV"] = "testing"
|
session.env["SPIFFWORKFLOW_BACKEND_ENV"] = "unit_testing"
|
||||||
session.run("flask", "db", "upgrade")
|
session.run("flask", "db", "upgrade")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ def create_app() -> flask.app.Flask:
|
||||||
|
|
||||||
def get_hacked_up_app_for_script() -> flask.app.Flask:
|
def get_hacked_up_app_for_script() -> flask.app.Flask:
|
||||||
"""Get_hacked_up_app_for_script."""
|
"""Get_hacked_up_app_for_script."""
|
||||||
os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "development"
|
os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "local_development"
|
||||||
flask_env_key = "FLASK_SESSION_SECRET_KEY"
|
flask_env_key = "FLASK_SESSION_SECRET_KEY"
|
||||||
os.environ[flask_env_key] = "whatevs"
|
os.environ[flask_env_key] = "whatevs"
|
||||||
if "BPMN_SPEC_ABSOLUTE_DIR" not in os.environ:
|
if "BPMN_SPEC_ABSOLUTE_DIR" not in os.environ:
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
from os import environ
|
from os import environ
|
||||||
|
|
||||||
SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME = environ.get(
|
SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME = environ.get(
|
||||||
"SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME", default="development.yml"
|
"SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME", default="local_development.yml"
|
||||||
)
|
)
|
||||||
|
|
||||||
SPIFFWORKFLOW_BACKEND_LOG_LEVEL = environ.get(
|
SPIFFWORKFLOW_BACKEND_LOG_LEVEL = environ.get(
|
|
@ -4,5 +4,7 @@ from os import environ
|
||||||
SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME = environ.get(
|
SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME = environ.get(
|
||||||
"SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME", default="qa1.yml"
|
"SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME", default="qa1.yml"
|
||||||
)
|
)
|
||||||
|
SPIFFWORKFLOW_FRONTEND_URL = "https://qa2.spiffworkflow.org"
|
||||||
OPEN_ID_SERVER_URL = "https://keycloak.qa1.spiffworkflow.org/realms/spiffworkflow"
|
OPEN_ID_SERVER_URL = "https://qa2.spiffworkflow.org/keycloak/realms/spiffworkflow"
|
||||||
|
SPIFFWORKFLOW_BACKEND_URL = "https://qa2.spiffworkflow.org/api"
|
||||||
|
CONNECTOR_PROXY_URL = "https://qa2.spiffworkflow.org/connector-proxy"
|
||||||
|
|
|
@ -9,7 +9,7 @@ SPIFFWORKFLOW_BACKEND_LOG_TO_FILE = (
|
||||||
)
|
)
|
||||||
|
|
||||||
SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME = environ.get(
|
SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME = environ.get(
|
||||||
"SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME", default="testing.yml"
|
"SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME", default="unit_testing.yml"
|
||||||
)
|
)
|
||||||
|
|
||||||
SPIFFWORKFLOW_BACKEND_LOG_LEVEL = environ.get(
|
SPIFFWORKFLOW_BACKEND_LOG_LEVEL = environ.get(
|
|
@ -136,7 +136,7 @@ def setup_logger(app: Flask) -> None:
|
||||||
|
|
||||||
# the json formatter is nice for real environments but makes
|
# the json formatter is nice for real environments but makes
|
||||||
# debugging locally a little more difficult
|
# debugging locally a little more difficult
|
||||||
if app.config["ENV_IDENTIFIER"] != "development":
|
if app.config["ENV_IDENTIFIER"] != "local_development":
|
||||||
json_formatter = JsonFormatter(
|
json_formatter = JsonFormatter(
|
||||||
{
|
{
|
||||||
"level": "levelname",
|
"level": "levelname",
|
||||||
|
|
|
@ -20,4 +20,4 @@ class TestEnvironmentVarScript(BaseTest):
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
script_engine = ProcessInstanceProcessor._script_engine
|
script_engine = ProcessInstanceProcessor._script_engine
|
||||||
result = script_engine._evaluate("get_env()", {})
|
result = script_engine._evaluate("get_env()", {})
|
||||||
assert result == "testing"
|
assert result == "unit_testing"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { port, hostname } = window.location;
|
const { port, hostname } = window.location;
|
||||||
let hostAndPort = `api.${hostname}`;
|
let hostAndPort = hostname;
|
||||||
let protocol = 'https';
|
let protocol = 'https';
|
||||||
|
|
||||||
if (/^\d+\./.test(hostname) || hostname === 'localhost') {
|
if (/^\d+\./.test(hostname) || hostname === 'localhost') {
|
||||||
|
@ -11,7 +11,7 @@ if (/^\d+\./.test(hostname) || hostname === 'localhost') {
|
||||||
protocol = 'http';
|
protocol = 'http';
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = `${protocol}://${hostAndPort}/v1.0`;
|
let url = `${protocol}://${hostAndPort}/api/v1.0`;
|
||||||
if (process.env.REACT_APP_BACKEND_BASE_URL) {
|
if (process.env.REACT_APP_BACKEND_BASE_URL) {
|
||||||
url = process.env.REACT_APP_BACKEND_BASE_URL;
|
url = process.env.REACT_APP_BACKEND_BASE_URL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue