Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Flags for customizing service creation and links #64

Open
12 of 18 tasks
josegonzalez opened this issue Aug 29, 2016 · 11 comments
Open
12 of 18 tasks

[RFC] Flags for customizing service creation and links #64

josegonzalez opened this issue Aug 29, 2016 · 11 comments

Comments

@josegonzalez
Copy link
Member

josegonzalez commented Aug 29, 2016

Rather than have a bunch of semi-related issues open, I'll open a single issue to track the various flags we want to add:

Creation Flags

We currently allow some values to be configured via environment variables. This doesn't work as well when users are running commands over ssh. We should instead allow users to specify any of these initial values during the creation step.

  • service:create: Add the ability to specify a flag --config-options "OPTS" to define any extra options.
    • Mongo specific
  • service:create: Add the ability to specify a flag --custom-env "USER=alpha;HOST=beta" to define the custom env.
  • service:create: Add the ability to specify a flag --image IMAGE to define the image name.
  • service:create: Add the ability to specify a flag --image-version IMAGE_VERSION to define the image version.
  • service:create: Add the ability to specify a flag --password PASSWORD to define the password.
    • Should include a warning that doing this may not be as secure as our random password.
  • service:create: Add the ability to specify a flag --root-password PASSWORD to define the root password.
    • Should include a warning that doing this may not be as secure as our random password.

Clone Flags

Upgrading/Downgrading is now impossible since dokku/dokku-postgres@6a86efc, and we should allow folks to easily override the environment variables via flags.

  • service:clone: Add the ability to specify a flag --image IMAGE to define the image name.
  • service:clone: Add the ability to specify a flag --image-version IMAGE_VERSION to define the image version.

Link Aliases

We have a finite number of services that can be linked at once to an application, limited by a hardcoded list of colors. When that list is depleted, we'll have an infinite loop where we cannot link a service to an app. Users may also wish to specify the exact alias being used for the link so that it is easy to predict what the url for a service will be.

  • service:link: Fail hard when the max number of automatic alias names is reached.
  • service:link: Add the ability to specify a flag --alias ALIAS for the purposes of defining the exact link alias.
    • The link value should not be prefixed or suffixed with either the name of the plugin or _URL.

Memcached Memory Limit

Memcached is currently limited to 64 megabytes. This is probably good for most of our users - people use Dokku on memory-limited servers - but there are cases where they may wish to use more memory.

  • service:create: Add the ability to specify a flag --memory MB for the purposes of defining the memory in use.
    • Default to 64, and write this value to disk. This should be used anytime the container is recreated.

Export Options

  • Locking tables dokku-mariadb#56

  • service:export: Add the ability to specify a flag --export-options "OPTS" to define any extra options.

    • Mariadb/MySQL specific
    • Ignore for the backup automation commands for now.

Querystring Values

Some frameworks use querystring values as a way to specify conditions for the connection. For instance, you might set the connection collation or pool size.

  • service:link: Add the ability to specify a flag --querystring "key=value&key=value".
    • Validate that the querystring does not begin with a ?. Chop it off it is is there.
    • Do not perform any other validation on this value. If people want to screw it up, not much we can do.
    • Just append it to the end of the url if it is non-zero in length, after a ?.

Single Container Usage

Users on smaller VPSs will want to save memory by not running many containers for a database service. This will allow us to mark all community service plugins as deprecated.

  • service:create-database <service> <database-name>: Create this command.
    • Store the list of databases in /var/lib/dokku/services/postgres/SERVICE/databases/NAME, where each file is simply the name of a database.
  • service:create: Store the user/pass info on disk in a new format:
    • Store the user/pass info in a set of files located in /var/lib/dokku/services/postgres/SERVICE/auth/USERNAME, where the username is the name of the user, and the contents are the password. Note that we will need to migrate all the old auth stuff over, including any root users.
    • Users will have access to everything in the service. If a developer needs to lockdown a specific user, that's on them to coordinate later.
  • service:create-user <service> <username> <password>: Create this command.
  • service:link: Add the ability to specify a flag --user USERNAME to specify the user that will be set for a specific link.
  • service:link: Add the ability to specify a flag --database DATABASE to specify the database that will be set for a specific link.
@josegonzalez
Copy link
Member Author

josegonzalez commented Sep 13, 2016

Useful stackoverflow comment on argparsing. Repost follows:


As other people explained, getopts doesn't parse long options. You can use getopt, but it's not portable (and it is broken on some platform...)

As a workaround, you can implement a shell loop. Here an example that transforms long options to short ones before using the standard getopts command (it's simpler in my opinion):

# Transform long options to short ones
for arg in "$@"; do
  shift
  case "$arg" in
    "--help") set -- "$@" "-h" ;;
    "--rest") set -- "$@" "-r" ;;
    "--ws")   set -- "$@" "-w" ;;
    *)        set -- "$@" "$arg"
  esac
done

# Default behavior
rest=false; ws=false

# Parse short options
OPTIND=1
while getopts "hrw" opt
do
  case "$opt" in
    "h") print_usage; exit 0 ;;
    "r") rest=true ;;
    "w") ws=true ;;
    "?") print_usage >&2; exit 1 ;;
  esac
done
shift $(expr $OPTIND - 1) # remove options from positional parameters

@MichaelSp
Copy link

Is there an ETA for the "Single Container"-Feature?

@josegonzalez
Copy link
Member Author

Whenever I get to it. Dokku doesn't pay the bills, so if you want to help change that, let me know and I can get you an ETA.

@javierav
Copy link

@josegonzalez I am interested in the "Single Container" feature, how can I help with this issue?

josegonzalez added a commit that referenced this issue Aug 26, 2017
josegonzalez added a commit to dokku/dokku-couchdb that referenced this issue Aug 26, 2017
josegonzalez added a commit to dokku/dokku-elasticsearch that referenced this issue Aug 26, 2017
josegonzalez added a commit to dokku/dokku-graphite that referenced this issue Aug 26, 2017
josegonzalez added a commit to dokku/dokku-mariadb that referenced this issue Aug 26, 2017
josegonzalez added a commit to dokku/dokku-memcached that referenced this issue Aug 26, 2017
josegonzalez added a commit to dokku/dokku-mongo that referenced this issue Aug 26, 2017
josegonzalez added a commit to dokku/dokku-mysql that referenced this issue Aug 26, 2017
josegonzalez added a commit to dokku/dokku-mariadb that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-memcached that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-mongo that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-mysql that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-nats that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-postgres that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-rabbitmq that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-rethinkdb that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-solr that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-couchdb that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-elasticsearch that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-graphite that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-mariadb that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-memcached that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-mongo that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-mysql that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-nats that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-postgres that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-rabbitmq that referenced this issue Apr 24, 2018
josegonzalez added a commit that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-rethinkdb that referenced this issue Apr 24, 2018
josegonzalez added a commit to dokku/dokku-solr that referenced this issue Apr 24, 2018
@decentral1se
Copy link
Member

🎉 🎉 🎉

@Alir3z4
Copy link

Alir3z4 commented Jun 9, 2020

Could postgresql container memory limit get included in that list ?

Ref dokku/dokku-postgres#188

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants