Skip to content

Commit

Permalink
Switch from buildpack to image, set required variables
Browse files Browse the repository at this point in the history
We're not tackling how to parse postgres service details out of
VCAP_SERVICES just yet, sticking with sqlite for now.
  • Loading branch information
mogul committed Mar 29, 2024
1 parent 892a14c commit 41cce00
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 40 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ UNKNOWN.egg-info/
process_models/
.ipynb_checkpoints
.env*
.cache
.cache
vars.yml
88 changes: 56 additions & 32 deletions manifest.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
defaults: &defaults
random-route: true
services:
- ((db-instance))
disk_quota: 3G
Expand All @@ -12,15 +11,26 @@ applications:
################################
- name: spiffworkflow-frontend
<<: *defaults
routes:
- route: spiffworkflow-((randomish-route)).app.cloud.gov
docker:
image: ((frontend-image))
env:
APPLICATION_ROOT: "/"

# Look for the backend on subpath "/api" of the app... I think.
PORT0: "8080"
SPIFFWORKFLOW_FRONTEND_RUNTIME_CONFIG_APP_ROUTING_STRATEGY: "path_based"

SPIFFWORKFLOW_FRONTEND_RUNTIME_CONFIG_BACKEND_BASE_URL: "https://spiffworkflow-((randomish-route)).app.cloud.gov/api"
BACKEND_BASE_URL: "https://spiffworkflow-((randomish-route)).app.cloud.gov/api"
# We may need to set BACKEND_URL; see spiffworkflow-frontend/src/config/tsx:15-72

# WHERE WE STOPPED:
# spiffworkflow-backend/src/spiffworkflow_backend/routes/authentication_controller.py#L111-L112
# We are hitting: https://spiffworkflow-flamingo-stardust.app.cloud.gov/api/v1.0/login?redirect_url=https://spiffworkflow-flamingo-stardust.app.cloud.gov/&authentication_identifier=default
# We are seeing: {
# "error_code": "internal_server_error",
# "message": "InvalidRedirectUrlError: Invalid redirect url was given: 'https://spiffworkflow-flamingo-stardust.app.cloud.gov/'. It must match the domain the frontend is running on.",
# "status_code": 500
# }

# Other vars this image understands:
# CYPRESS_RECORD_KEY
Expand All @@ -35,43 +45,57 @@ applications:

- name: spiffworkflow-backend
<<: *defaults
command: DATABASE_URL="$(echo $VCAP_SERVICES | jq --raw-output --arg service_name "((db-instance))" ".[][] | select(.name == \$service_name) | .credentials.uri")?sslmode=require" /app/bin/boot_server_in_docker
disk_quota: 3G
health_check_type: process
routes:
- route: spiffworkflow-((randomish-route)).app.cloud.gov/api

# With buildpack:
path: spiffworkflow-backend
buildpacks:
- python_buildpack
# path: spiffworkflow-backend
# buildpacks:
# - python_buildpack
# command: DATABASE_URL="$(echo $VCAP_SERVICES | jq --raw-output --arg service_name "((db-instance))" ".[][] | select(.name == \$service_name) | .credentials.uri")?sslmode=require" bin/boot_server_in_docker

# With Docker:
# docker:
# image: ((backend-image))
docker:
image: ((backend-image))
command: /app/bin/boot_server_in_docker
# command: sleep 6000

env:
APPLICATION_ROOT: "/"
SPIFFWORKFLOW_BACKEND_DATABASE_TYPE: "postgres"

# All of the configuration variables are documented here:
# https://github.com/sartography/spiff-arena/blob/main/spiffworkflow-backend/src/spiffworkflow_backend/config/default.py

### Requires VCAP env vars

# SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME=example.yml SPIFFWORKFLOW_BACKEND_DATABASE_TYPE=sqlite SPIFFWORKFLOW_BACKEND_ENV=local_docker SPIFFWORKFLOW_BACKEND_RUN_BACKGROUND_SCHEDULER_IN_CREATE_APP=true FLASK_DEBUG=0 FLASK_SESSION_SECRET_KEY=HEY SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR="${HOME}/projects/github/sartography/sample-process-models/" ./bin/boot_server_in_docker
# VCAP_SERVICES
SPIFFWORKFLOW_BACKEND_DATABASE_URI: "sqlite:///db.sqlite3"

# Hardcoded
FLASK_DEBUG: "0"
APPLICATION_ROOT: "/"
SPIFFWORKFLOW_BACKEND_APPLICATION_ROOT: "/api"
SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR: "/app/process_models"
# spiffworkflow_backend.config.ConfigurationError: SPIFFWORKFLOW_BACKEND_URL_FOR_FRONTEND and SPIFFWORKFLOW_BACKEND_URL are incompatible. We need backend to set cookies for frontend, so they need to be on the same domain. A common setup is to have frontend on example.com and backend on api.example.com. If you do not need this functionality, you can avoid this check by setting environment variable SPIFFWORKFLOW_BACKEND_CHECK_FRONTEND_AND_BACKEND_URL_COMPATIBILITY=false
SPIFFWORKFLOW_BACKEND_CHECK_FRONTEND_AND_BACKEND_URL_COMPATIBILITY: "false"
SPIFFWORKFLOW_BACKEND_ENV: "local_docker"
SPIFFWORKFLOW_BACKEND_DATABASE_TYPE: "sqlite"
SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA: "false"
SPIFFWORKFLOW_BACKEND_LOG_LEVEL: "DEBUG"
SPIFFWORKFLOW_BACKEND_OPEN_ID_CLIENT_ID: "spiffworkflow-backend"
SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME: "example.yml"
SPIFFWORKFLOW_BACKEND_PORT: "8080"
SPIFFWORKFLOW_BACKEND_RUN_BACKGROUND_SCHEDULER_IN_CREATE_APP: "true"
SPIFFWORKFLOW_BACKEND_UPGRADE_DB: "true"

# vars.yml (or CLI)
FLASK_SESSION_SECRET_KEY: ((flask-session-key))
SPIFFWORKFLOW_BACKEND_OPEN_ID_CLIENT_SECRET_KEY: "((openid-secret))"
SPIFFWORKFLOW_BACKEND_OPEN_ID_SERVER_URL: "https://spiffworkflow-((randomish-route)).app.cloud.gov/api/openid"
SPIFFWORKFLOW_BACKEND_URL: "https://spiffworkflow-((randomish-route)).app.cloud.gov/api"
SPIFFWORKFLOW_BACKEND_URL_FOR_FRONTEND: "https://spiffworkflow-((randomish-route)).app.cloud.gov/api"
SPIFFWORKFLOW_BACKEND_CONNECTOR_PROXY_URL: "https://spiffworkflow-connector-((randomish-route)).app.cloud.gov"

# environment:
# - FLASK_DEBUG=0
# - FLASK_SESSION_SECRET_KEY=${FLASK_SESSION_SECRET_KEY:-e7711a3ba96c46c68e084a86952de16f}
# - SPIFFWORKFLOW_BACKEND_APPLICATION_ROOT=/
# - SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR=/app/process_models
# - SPIFFWORKFLOW_BACKEND_DATABASE_URI=mysql+mysqldb://root:${SPIFFWORKFLOW_BACKEND_MYSQL_ROOT_DATABASE:-my-secret-pw}@127.0.0.1:7003/${SPIFFWORKFLOW_BACKEND_DATABASE_NAME:-spiffworkflow_backend_development}
# - SPIFFWORKFLOW_BACKEND_ENV=${SPIFFWORKFLOW_BACKEND_ENV:-local_development}
# - SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA=${SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA:-false}
# - SPIFFWORKFLOW_BACKEND_OPEN_ID_SERVER_URL=${SPIFFWORKFLOW_BACKEND_OPEN_ID_SERVER_URL:-http://localhost:7002/realms/spiffworkflow}
# - SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME=${SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME:-acceptance_tests.yml}
# - SPIFFWORKFLOW_BACKEND_PORT=7000
# # the background scheduler picks up process instances that we set in a certain state and then runs them like running not_started instances
# # that are required for the process instance filter test. So for now do not run it. we may want to find another way around in the future
# - SPIFFWORKFLOW_BACKEND_RUN_BACKGROUND_SCHEDULER_IN_CREATE_APP=false
# - SPIFFWORKFLOW_BACKEND_URL_FOR_FRONTEND=${SPIFFWORKFLOW_BACKEND_URL_FOR_FRONTEND:-http://localhost:7001}
# - SPIFFWORKFLOW_BACKEND_UPGRADE_DB=true
# - SPIFFWORKFLOW_BACKEND_URL=${SPIFFWORKFLOW_BACKEND_URL:-http://localhost:7000}
# - SPIFFWORKFLOW_BACKEND_OPEN_ID_SERVER_URL=http://localhost:7002/realms/spiffworkflow

# All of the configuration variables are documented here:
# https://github.com/sartography/spiff-arena/blob/main/spiffworkflow-backend/src/spiffworkflow_backend/config/default.py
5 changes: 0 additions & 5 deletions spiffworkflow-backend/.profile

This file was deleted.

7 changes: 5 additions & 2 deletions vars.yml → vars.yml-template
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
frontend-image: ghcr.io/gsa-tts/spiffworkflow-frontend:deploy-to-cloud-gov-latest
backend-image: ghcr.io/gsa-tts/spiffworkflow-backend:deploy-to-cloud-gov-latest
frontend-image: ghcr.io/gsa-tts/spiffworkflow-frontend:deploy-to-cloud-gov-latest

db-instance: spiffworkflow-db
flask-testing-key: 66eef9e98a3f4e6f85258154e4a1bdce
flask-session-key: 66eef9e98a3f4e6f85258154e4a1bdce
openid-secret: flarblegarble
randomish-route: flamingo-stardust

0 comments on commit 41cce00

Please sign in to comment.