plotly / de-deploy

A reusable Github action for deploying to DE5

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for `.service` file

ndrezn opened this issue · comments

For applications which require services like Redis or Postgres, a standard file (probably .service) would be useful to recognize and automatically spin up those services for the app. This is especially useful as part of the deploy preview, which would be frustrating to use for now for apps which depend on those resources.

We can accomplish this with logic along the lines of:

SERVICE_FILEPATH = os.environ.get("SERVICEFILEPATH")
METHOD = os.environ.get("METHOD")

if SERVICE_FILEPATH:
    with open(SERVICE_FILEPATH, 'r') as svc_file:
        service_configs = json.load(svc_file)
        if not isinstance(service_configs, list):
            service_configs = [service_configs]

if METHOD == "CHECKSVC":
    for service in service_configs:
        push = "false" if connection.serviceExists(APP, service['type']) else "true"
        if push == "true":
            print(push)

in manage_apps.py and logic along the lines of:

# Check if service needs to be created
if [[ -f "$APPS_DIR/$APP/.service" ]]; then
  service_file="$APPS_DIR/$APP/.service"
  create_svc=true
fi

if [[ "$create_svc" == "true" ]]; then
  APP=$with_suffix METHOD="CREATESVC" SERVICEFILEPATH=$service_file python ./manage_apps.py
fi

in deploy.sh.