gorules / zen

Open-source Business Rules Engine for your Rust, NodeJS, Python or Go applications.
https://gorules.io
MIT License
810 stars 76 forks source link

Ability to change the PORT mapping for the web application #227

Open lockhinator opened 2 months ago

lockhinator commented 2 months ago

We are in the process of deploying a self-hosted instance of GoRules on Heroku. As you may know, Heroku dynamically assigns a port to applications internally within their infrastructure. Therefore, we need the capability to configure the web application's port, ideally through an environment variable.

Could you please confirm if this functionality is currently supported? If not, is there a possibility it could be supported in the near future?

stefan-gorules commented 2 months ago

Hi, this is something we can take a look in. Would you be able to provide more details around your set-up in Heroku?

From what I've seen from quick google search, deployment of Docker images in Heroku works by:

Appreciate it!

lockhinator commented 2 months ago

Hi, this is something we can take a look in. Would you be able to provide more details around your set-up in Heroku?

From what I've seen from quick google search, deployment of Docker images in Heroku works by:

  • Pulling the image from docker.io registry
  • Pushing the image to Heroku registry
  • Deploying the container

Appreciate it!

We are currently using the image and running it via a heroku.yml file as well as doing some env setting in a startup bash script. Here are both files for context:

# heroku.yml
setup:
  addons:
    - plan: heroku-postgresql
      as: DATABASE

build:
  docker:
    gorules: Dockerfile

run:
  web:
    image: gorules
#!/bin/bash

# Extract the components from DATABASE_URL
if [ -n "$DATABASE_URL" ]; then
    # Remove the protocol (e.g., "postgres://")
    url=${DATABASE_URL#*//}

    # Extract the user and password
    userpass=${url%%@*}
    export DB_USER=${userpass%%:*}
    export DB_PASSWORD=${userpass#*:}

    # Extract the host and port
    hostport=${url#*@}
    hostport=${hostport%%/*}
    export DB_HOST=${hostport%%:*}
    export DB_PORT=${hostport#*:}

    # Extract the database name
    export DB_NAME=${url##*/}
fi

# Start the application
docker run gorules

We are using the PostgreSQL addon for PostgreSQL which mounts the DATABASE_URL into the dyno via Heroku's backend. Because of this we leverage the start.sh script but do not have the ability to change the port for the frontend in this case as it is assigned by Heroku.