diff --git a/scripts/heroku-apps/Dockerfile b/scripts/heroku-apps/Dockerfile new file mode 100644 index 0000000..bf73d74 --- /dev/null +++ b/scripts/heroku-apps/Dockerfile @@ -0,0 +1,12 @@ +FROM ruby:2.7.7-bullseye + +WORKDIR /app + +COPY ["Gemfile", "/app/Gemfile"] +COPY ["Gemfile.lock", "/app/Gemfile.lock"] + +run bundle install + +COPY ["heroku-apps.rb", "/app/heroku-apps.rb"] + +ENTRYPOINT ["ruby", "heroku-apps.rb"] diff --git a/scripts/heroku-apps/Gemfile b/scripts/heroku-apps/Gemfile index 2e1cf7c..50d0069 100644 --- a/scripts/heroku-apps/Gemfile +++ b/scripts/heroku-apps/Gemfile @@ -1,3 +1,5 @@ +source 'https://rubygems.org' + ruby '< 3.0' gem 'platform-api' diff --git a/scripts/heroku-apps/README.md b/scripts/heroku-apps/README.md index 488e1cc..8307f07 100644 --- a/scripts/heroku-apps/README.md +++ b/scripts/heroku-apps/README.md @@ -72,3 +72,31 @@ Deletes all apps beginning with the common app prefix. Remove from the Heroku team all team members whose emails appear in the CSV file. (This allows for leaving team members who are course staff, e.g.) + +## Running with Docker + +Instead of switching to the right Ruby version manually, you can also build and use a Docker image to run this script. + +### To build + +To create the Docker image, clone this repository, cd into the script directory, and run: + +``` +docker build -t saasbook-script-heroku-apps . +``` + +### To run + +Run the following, replacing the appropriate parameters. + +If using Windows, you may need to change the `` `pwd` `` mount. Files in the working directory will be available to the container at `/app/files`, e.g. `-c /app/files/team-info.csv`. + +``` +docker run \ + -it \ + -v `pwd`:/app/files \ + -e HEROKU_API_KEY=[your_key] \ + saasbook-script-heroku-apps \ + [args] \ + [command] +``` diff --git a/scripts/heroku-apps/heroku-apps b/scripts/heroku-apps/heroku-apps.rb similarity index 98% rename from scripts/heroku-apps/heroku-apps rename to scripts/heroku-apps/heroku-apps.rb index 4ed4a73..a0c5efe 100755 --- a/scripts/heroku-apps/heroku-apps +++ b/scripts/heroku-apps/heroku-apps.rb @@ -20,7 +20,7 @@ def main() h.heroku_team = team end opt.on('-pPREFIX', '--prefix=PREFIX', 'App name prefix, eg "fa23" gives apps "fa23-01", "fa23-02", etc.') do |pfx| - h.app_prefix = pfx + h.app_prefix = if pfx.end_with? '-' then pfx else "#{pfx}-" end end opt.on('-xEMAILS' '--extra-users=EMAILS', 'Comma-separated list of emails that should also be collaborators on apps') do |extra_users| h.extra_users = extra_users.split(/,/)