diff --git a/.openshift/action_hooks/build b/.openshift/action_hooks/build deleted file mode 100755 index 42b073ff..00000000 --- a/.openshift/action_hooks/build +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -# This is a simple build script and will be executed on your CI system if -# available. Otherwise it will execute while your application is stopped -# before the deploy step. This script gets executed directly, so it -# could be python, php, ruby, etc. - -echo "-> Build step" \ No newline at end of file diff --git a/.openshift/action_hooks/deploy b/.openshift/action_hooks/deploy deleted file mode 100755 index d6855a8f..00000000 --- a/.openshift/action_hooks/deploy +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# This deploy hook gets executed after dependencies are resolved and the -# build hook has been run but before the application has been started back -# up again. This script gets executed directly, so it could be python, php, -# ruby, etc. - -echo "-> Deploy step" - -pushd ${OPENSHIFT_REPO_DIR} > /dev/null - -STORED_ASSETS="${OPENSHIFT_DATA_DIR}/assets" -LIVE_ASSETS="${OPENSHIFT_REPO_DIR}/public/assets" - -# Ensure our stored assets directory exists -if [ ! -d "${STORED_ASSETS}" ]; then - echo " Creating permanent assets directory" - mkdir "${STORED_ASSETS}" -fi - -# Create symlink to stored assets unless we're uploading our own assets -if [ -d "${LIVE_ASSETS}" ]; then - echo " WARNING: Assets included in git repository, not using stored assets" -else - echo " Restoring stored assets" - \ln -sf "${STORED_ASSETS}" "${LIVE_ASSETS}" -fi - -source ${OPENSHIFT_REPO_DIR}/.env - -mkdir -p log tmp/pids tmp/sockets - -echo "jobs: bundle exec rails runner bin/threaded.rb" > Procfile - -\sed -r -i -e "s@^ *set :deploy_to.+@set :deploy_to, '${OPENSHIFT_REPO_DIR}'@" config/deploy.rb - -echo "Migrating" -bundle exec rake db:migrate RAILS_ENV=production - -popd > /dev/null diff --git a/.openshift/action_hooks/post_deploy b/.openshift/action_hooks/post_deploy deleted file mode 100755 index 3851db86..00000000 --- a/.openshift/action_hooks/post_deploy +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# This is a simple post deploy hook executed after your application -# is deployed and started. This script gets executed directly, so -# it could be python, php, ruby, etc. - -echo "-> Post deploy step" \ No newline at end of file diff --git a/.openshift/action_hooks/post_start_ruby-2.0 b/.openshift/action_hooks/post_start_ruby-2.0 deleted file mode 100755 index 32988106..00000000 --- a/.openshift/action_hooks/post_start_ruby-2.0 +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# The pre_start_cartridge and pre_stop_cartridge hooks are *SOURCED* -# immediately before (re)starting or stopping the specified cartridge. -# They are able to make any desired environment variable changes as -# well as other adjustments to the application environment. - -# The post_start_cartridge and post_stop_cartridge hooks are executed -# immediately after (re)starting or stopping the specified cartridge. - -# Exercise caution when adding commands to these hooks. They can -# prevent your application from stopping cleanly or starting at all. -# Application start and stop is subject to different timeouts -# throughout the system. - -echo "-> Post start ruby step" \ No newline at end of file diff --git a/.openshift/action_hooks/post_stop_ruby-2.0 b/.openshift/action_hooks/post_stop_ruby-2.0 deleted file mode 100755 index 0af86bb6..00000000 --- a/.openshift/action_hooks/post_stop_ruby-2.0 +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# The pre_start_cartridge and pre_stop_cartridge hooks are *SOURCED* -# immediately before (re)starting or stopping the specified cartridge. -# They are able to make any desired environment variable changes as -# well as other adjustments to the application environment. - -# The post_start_cartridge and post_stop_cartridge hooks are executed -# immediately after (re)starting or stopping the specified cartridge. - -# Exercise caution when adding commands to these hooks. They can -# prevent your application from stopping cleanly or starting at all. -# Application start and stop is subject to different timeouts -# throughout the system. - -echo "-> Post stop ruby step" \ No newline at end of file diff --git a/.openshift/action_hooks/pre_build b/.openshift/action_hooks/pre_build deleted file mode 100755 index 84f1b4f6..00000000 --- a/.openshift/action_hooks/pre_build +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# This is a simple script and will be executed on your CI system if -# available. Otherwise it will execute while your application is stopped -# before the build step. This script gets executed directly, so it -# could be python, php, ruby, etc. - -echo "-> Pre-build step" - -pushd ${OPENSHIFT_REPO_DIR} > /dev/null - -cp -a -f .env.example .env - -\sed -r -i -e "s/^#? *DOMAIN *=.+/DOMAIN=${OPENSHIFT_APP_DNS}:80/" \ - -e "s/^#? *PORT *=.+/PORT=80/" .env - -\sed -r -i -e "s/^#? *DATABASE_ENCODING *=.+/DATABASE_ENCODING=utf8/" \ - -e "s/^#? *DATABASE_NAME *=.+/DATABASE_NAME=${OPENSHIFT_APP_NAME}/" \ - -e "s/^#? *DATABASE_USERNAME *=.+/DATABASE_USERNAME=${OPENSHIFT_MYSQL_DB_USERNAME}/" \ - -e "s/^#? *DATABASE_PASSWORD *=.+/DATABASE_PASSWORD=${OPENSHIFT_MYSQL_DB_PASSWORD}/" \ - -e "s/^#? *DATABASE_HOST *=.+/DATABASE_HOST=${OPENSHIFT_MYSQL_DB_HOST}/" \ - -e "s/^#? *DATABASE_PORT *=.+/DATABASE_PORT=${OPENSHIFT_MYSQL_DB_PORT}/" \ - -e "s@^#? *DATABASE_SOCKET *=.+@DATABASE_SOCKET=${OPENSHIFT_MYSQL_DB_SOCKET}@" .env - -# Just for completeness; not strictly necessary -\sed -r -i -e "s/^#? *APP_SECRET_TOKEN *=.+/APP_SECRET_TOKEN=${APP_SECRET_TOKEN}/" \ - -e "s/^#? *RAILS_ENV *=.+/RAILS_ENV=production/" \ - -e "s/^#? *INVITATION_CODE *=.+/INVITATION_CODE=${INVITATION_CODE}/" .env - -\sed -r -i -e "s/^#? *SMTP_DOMAIN *=.+/SMTP_DOMAIN=${SMTP_DOMAIN}/" \ - -e "s/^#? *SMTP_USER_NAME *=.+/SMTP_USER_NAME=${SMTP_USER_NAME}/" \ - -e "s/^#? *SMTP_PASSWORD *=.+/SMTP_PASSWORD=${SMTP_PASSWORD}/" \ - -e "s/^#? *SMTP_SERVER *=.+/SMTP_SERVER=${SMTP_SERVER}/" \ - -e "s/^#? *EMAIL_FROM_ADDRESS *=.+/EMAIL_FROM_ADDRESS=${SMTP_USER_NAME}/" .env - -\sed -r -i -e 's/^#?(.+= *)$/#\1/' .env - -chmod ugo+r ${OPENSHIFT_REPO_DIR}/.env - -source ${OPENSHIFT_REPO_DIR}/.env diff --git a/.openshift/action_hooks/pre_start_ruby-2.0 b/.openshift/action_hooks/pre_start_ruby-2.0 deleted file mode 100755 index 04cbea8e..00000000 --- a/.openshift/action_hooks/pre_start_ruby-2.0 +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# The pre_start_cartridge and pre_stop_cartridge hooks are *SOURCED* -# immediately before (re)starting or stopping the specified cartridge. -# They are able to make any desired environment variable changes as -# well as other adjustments to the application environment. - -# The post_start_cartridge and post_stop_cartridge hooks are executed -# immediately after (re)starting or stopping the specified cartridge. - -# Exercise caution when adding commands to these hooks. They can -# prevent your application from stopping cleanly or starting at all. -# Application start and stop is subject to different timeouts -# throughout the system. - -echo "-> Pro start ruby step" - -if [ -f ${OPENSHIFT_REPO_DIR}/.env ] -then - source ${OPENSHIFT_REPO_DIR}/.env -fi diff --git a/.openshift/action_hooks/pre_stop_ruby-2.0 b/.openshift/action_hooks/pre_stop_ruby-2.0 deleted file mode 100755 index 22ee1943..00000000 --- a/.openshift/action_hooks/pre_stop_ruby-2.0 +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# The pre_start_cartridge and pre_stop_cartridge hooks are *SOURCED* -# immediately before (re)starting or stopping the specified cartridge. -# They are able to make any desired environment variable changes as -# well as other adjustments to the application environment. - -# The post_start_cartridge and post_stop_cartridge hooks are executed -# immediately after (re)starting or stopping the specified cartridge. - -# Exercise caution when adding commands to these hooks. They can -# prevent your application from stopping cleanly or starting at all. -# Application start and stop is subject to different timeouts -# throughout the system. - -echo "-> Pre stop ruby step" \ No newline at end of file diff --git a/.openshift/cron/README.cron b/.openshift/cron/README.cron deleted file mode 100644 index 6a2593fd..00000000 --- a/.openshift/cron/README.cron +++ /dev/null @@ -1,22 +0,0 @@ -Run scripts or jobs on a periodic basis -======================================= -Any scripts or jobs added to the minutely, hourly, daily, weekly or monthly -directories will be run on a scheduled basis (frequency is as indicated by the -name of the directory) using run-parts. - -run-parts ignores any files that are hidden or dotfiles (.*) or backup -files (*~ or *,) or named *.{rpmsave,rpmorig,rpmnew,swp,cfsaved} - -The presence of two specially named files jobs.deny and jobs.allow controls -how run-parts executes your scripts/jobs. - jobs.deny ===> Prevents specific scripts or jobs from being executed. - jobs.allow ===> Only execute the named scripts or jobs (all other/non-named - scripts that exist in this directory are ignored). - -The principles of jobs.deny and jobs.allow are the same as those of cron.deny -and cron.allow and are described in detail at: - http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/ch-Automating_System_Tasks.html#s2-autotasks-cron-access - -See: man crontab or above link for more details and see the the weekly/ - directory for an example. - diff --git a/.openshift/cron/daily/.gitignore b/.openshift/cron/daily/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/.openshift/cron/daily/logrotate b/.openshift/cron/daily/logrotate deleted file mode 100755 index 5693a9ea..00000000 --- a/.openshift/cron/daily/logrotate +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -pushd $OPENSHIFT_REPO_DIR - -/usr/sbin/logrotate -s log/logrotate.status .openshift/logrotate - -EXITVALUE=$? -if [ $EXITVALUE != 0 ]; then - echo "ALERT exited abnormally with [$EXITVALUE]" | /usr/bin/logshifter -tag logrotate -fi -exit 0 diff --git a/.openshift/cron/hourly/.gitignore b/.openshift/cron/hourly/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/.openshift/cron/minutely/.gitignore b/.openshift/cron/minutely/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/.openshift/cron/monthly/.gitignore b/.openshift/cron/monthly/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/.openshift/cron/weekly/README b/.openshift/cron/weekly/README deleted file mode 100644 index 7c3e659f..00000000 --- a/.openshift/cron/weekly/README +++ /dev/null @@ -1,16 +0,0 @@ -Run scripts or jobs on a weekly basis -===================================== -Any scripts or jobs added to this directory will be run on a scheduled basis -(weekly) using run-parts. - -run-parts ignores any files that are hidden or dotfiles (.*) or backup -files (*~ or *,) or named *.{rpmsave,rpmorig,rpmnew,swp,cfsaved} and handles -the files named jobs.deny and jobs.allow specially. - -In this specific example, the chronograph script is the only script or job file -executed on a weekly basis (due to white-listing it in jobs.allow). And the -README and chrono.dat file are ignored either as a result of being black-listed -in jobs.deny or because they are NOT white-listed in the jobs.allow file. - -For more details, please see ../README.cron file. - diff --git a/.openshift/cron/weekly/chrono.dat b/.openshift/cron/weekly/chrono.dat deleted file mode 100644 index fc4abb87..00000000 --- a/.openshift/cron/weekly/chrono.dat +++ /dev/null @@ -1 +0,0 @@ -Time And Relative D...n In Execution (Open)Shift! diff --git a/.openshift/cron/weekly/chronograph b/.openshift/cron/weekly/chronograph deleted file mode 100755 index 61de949f..00000000 --- a/.openshift/cron/weekly/chronograph +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -echo "`date`: `cat $(dirname \"$0\")/chrono.dat`" diff --git a/.openshift/cron/weekly/jobs.allow b/.openshift/cron/weekly/jobs.allow deleted file mode 100644 index 42b16276..00000000 --- a/.openshift/cron/weekly/jobs.allow +++ /dev/null @@ -1,12 +0,0 @@ -# -# Script or job files listed in here (one entry per line) will be -# executed on a weekly-basis. -# -# Example: The chronograph script will be executed weekly but the README -# and chrono.dat files in this directory will be ignored. -# -# The README file is actually ignored due to the entry in the -# jobs.deny which is checked before jobs.allow (this file). -# -chronograph - diff --git a/.openshift/cron/weekly/jobs.deny b/.openshift/cron/weekly/jobs.deny deleted file mode 100644 index 73c94500..00000000 --- a/.openshift/cron/weekly/jobs.deny +++ /dev/null @@ -1,7 +0,0 @@ -# -# Any script or job files listed in here (one entry per line) will NOT be -# executed (read as ignored by run-parts). -# - -README - diff --git a/.openshift/logrotate b/.openshift/logrotate deleted file mode 100644 index 61aba204..00000000 --- a/.openshift/logrotate +++ /dev/null @@ -1,10 +0,0 @@ -"log/*.log" { - compress - copytruncate - create - dateext - maxage 30 - missingok - rotate 4 - size 2 -} diff --git a/.openshift/markers/README b/.openshift/markers/README deleted file mode 100644 index abfa46ce..00000000 --- a/.openshift/markers/README +++ /dev/null @@ -1,8 +0,0 @@ -Markers -=========== - -Adding marker files to this directory will have the following effects: - -force_clean_build - Previous output from bundle install --deployment will be - removed and all gems will be reinstalled according to the current - Gemfile/Gemfile.lock. diff --git a/.s2i/bin/run b/.s2i/bin/run new file mode 100644 index 00000000..b9badd05 --- /dev/null +++ b/.s2i/bin/run @@ -0,0 +1,45 @@ +#!/bin/bash + +set -e + +if [[ "$DATABASE_HOST" =~ '_SERVICE_HOST' ]]; then + DATABASE_HOST=$(echo "$DATABASE_HOST" | tr '[:lower:]' '[:upper:]') + export DATABASE_HOST=${!DATABASE_HOST} + echo "---> DATABASE_HOST: ${DATABASE_HOST} ..." +fi + +if [[ "$DATABASE_PORT" =~ '_SERVICE_PORT' ]]; then + DATABASE_PORT=$(echo "$DATABASE_PORT" | tr '[:lower:]' '[:upper:]') + export DATABASE_PORT=${!DATABASE_PORT} + echo "---> DATABASE_PORT: ${DATABASE_PORT} ..." +fi + +if [ -z "${DO_NOT_CREATE_DATABASE}" ]; then + echo "---> Creating database ..." + bundle exec rake db:create +fi + +if [ -z "${DO_NOT_MIGRATE}" ]; then + echo "---> Migrating database ..." + bundle exec rake db:migrate +fi + +if [ -z "${DO_NOT_SEED}" ]; then + echo "---> Seeding database ..." + set +e + bundle exec rake db:seed + set -e +fi + +# Configure the unicorn server +mv config/unicorn.rb.example config/unicorn.rb +sed -ri 's/^listen .*$/listen ENV["PORT"]/' config/unicorn.rb +sed -ri 's/^stderr_path.*$//' config/unicorn.rb +sed -ri 's/^stdout_path.*$//' config/unicorn.rb + +export RACK_ENV=${RACK_ENV:-"production"} + +WORKER_CMD="${WORKER_CMD:-"unicorn -c ./deployment/heroku/unicorn.rb --listen 0.0.0.0:8080"}" + +echo "---> Executing command: ${WORKER_CMD}" +exec bundle exec ${WORKER_CMD} diff --git a/README.md b/README.md index 4514e2d4..af56b474 100644 --- a/README.md +++ b/README.md @@ -71,8 +71,8 @@ If you just want to play around, you can simply fork this repository, then perfo * Read the [wiki][wiki] for usage examples and to get started making new Agents. * Periodically run `git fetch upstream` and then `git checkout master && git merge upstream/master` to merge in the newest version of Huginn. -Note: By default, emails are intercepted in the `development` Rails environment, which is what you just setup. You can view -them at [http://localhost:3000/letter_opener](http://localhost:3000/letter_opener). If you'd like to send real emails via SMTP when playing +Note: By default, emails are intercepted in the `development` Rails environment, which is what you just setup. You can view +them at [http://localhost:3000/letter_opener](http://localhost:3000/letter_opener). If you'd like to send real emails via SMTP when playing with Huginn locally, set `SEND_EMAIL_IN_DEVELOPMENT` to `true` in your `.env` file. If you need more detailed instructions, see the [Novice setup guide][novice-setup-guide]. @@ -83,13 +83,13 @@ If you need more detailed instructions, see the [Novice setup guide][novice-setu ### Develop -All agents have specs! And there's also acceptance tests that simulate running Huginn in a headless browser. +All agents have specs! And there's also acceptance tests that simulate running Huginn in a headless browser. -* Install PhantomJS 2.1.1 or greater: - * Using [Node Package Manager](https://www.npmjs.com/): `npm install phantomjs` +* Install PhantomJS 2.1.1 or greater: + * Using [Node Package Manager](https://www.npmjs.com/): `npm install phantomjs` * Using [Homebrew](http://brew.sh/) on OSX `brew install phantomjs` * Run all specs with `bundle exec rspec` -* Run a specific spec with `bundle exec rspec path/to/specific/test_spec.rb`. +* Run a specific spec with `bundle exec rspec path/to/specific/test_spec.rb`. * Read more about rspec for rails [here](https://github.com/rspec/rspec-rails). ## Using Huginn Agent gems @@ -102,13 +102,19 @@ Our general intention is to encourage complex and specific Agents to be written ## Deployment +Please see [the Huginn Wiki](https://github.com/huginn/huginn/wiki#deploying-huginn) for detailed deployment strategies for different providers. + ### Heroku Try Huginn on Heroku: [![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy) (Takes a few minutes to setup. Read the [documentation](https://github.com/huginn/huginn/blob/master/doc/heroku/install.md) while you are waiting and be sure to click 'View it' after launch!) Huginn launches on the free version of Heroku [with significant limitations](https://github.com/huginn/huginn/blob/master/doc/heroku/install.md). For non-experimental use, we strongly recommend Heroku's 1GB paid plan or our Docker container. -Please see [the Huginn Wiki](https://github.com/huginn/huginn/wiki#deploying-huginn) for detailed deployment strategies for different providers. +### OpenShift Online (v3) + +Try Huginn on OpenShift Online (v3): `oc new-app -f https://raw.githubusercontent.com/huginn/huginn/master/openshift/templates/huginn-mysql.json` or `oc new-app -f https://raw.githubusercontent.com/huginn/huginn/master/openshift/templates/huginn-postgresql.json`. You can also use the web console to import either json file by going to "Add to Project" -> "Import YAML/JSON". + +If you are on the Starter plan, make sure to follow the [guide](https://docs.openshift.com/online/getting_started/beyond_the_basics.html#btb-creating-a-new-application-from-source-code) to remove any existing application. ### Manual installation on any server @@ -135,4 +141,3 @@ Huginn is provided under the MIT License. Huginn was originally created by [@cantino](https://github.com/cantino) in 2013. Since then, many people's dedicated contributions have made it what it is today. [![Build Status](https://travis-ci.org/huginn/huginn.svg)](https://travis-ci.org/huginn/huginn) [![Coverage Status](https://coveralls.io/repos/cantino/huginn/badge.svg)](https://coveralls.io/r/cantino/huginn) [![Dependency Status](https://gemnasium.com/huginn/huginn.svg)](https://gemnasium.com/huginn/huginn) [![Bountysource](https://www.bountysource.com/badge/tracker?tracker_id=282580)](https://www.bountysource.com/trackers/282580-huginn?utm_source=282580&utm_medium=shield&utm_campaign=TRACKER_BADGE) - diff --git a/bin/setup_openshift b/bin/setup_openshift deleted file mode 100755 index 09e62ead..00000000 --- a/bin/setup_openshift +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/bin/env ruby -require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'setup_tools')) -include SetupTools - -if ARGV.length > 0 - mode = ARGV.shift -else - mode = '' -end - -unless `which rhc` =~ /rhc/ - puts "It looks like the 'rhc' command line tool hasn't been installed yet. Please install" - puts "it with 'gem install rhc', run 'rhc setup', and then run this script again." - exit 1 -end - -def grab_openshift_config! - grab_config_with_cmd!("rhc env list") -end - -def set_env(key, value) - capture("rhc env set #{key}=#{value}") -end - -def check_login! - token_file = Dir[File.join(File.expand_path('~/.openshift'), 'token_*')].first - unless token_file - puts "It looks like you need to log in to OpenShift. Please run 'rhc setup' before continuing a choose the option to 'Generate a token now', then run bin/setup_openshift again." - exit 1 - end - - unless (Time.now - File.stat(token_file).mtime).to_i < 60 * 60 * 24 * 5 - puts "Please run 'rhc logout' and then 'rhc account' to refresh your session, then run bin/setup_openshift again." - exit 1 - end - - puts "Welcome #{`rhc account`.scan(/Login (.*?) on /).first.first}! It looks like you're logged into OpenShift." - puts -end - -check_login! - -info = capture("rhc app show") -just_made = false -if info =~ /must specify an application/i - ruby_cartridge = 'http://cartreflect-claytondev.rhcloud.com/reflect?github=baip/openshift-ruby-cartridge' - foreman_cartridge = 'http://cartreflect-claytondev.rhcloud.com/reflect?github=baip/openshift-foreman-cartridge' - cmd = "rhc app create huginn #{ruby_cartridge} mysql-5.5 #{foreman_cartridge} -s -r tmp-huginn" - puts "It looks like you don't have an OpenShift app set up yet for this repo. I can make one for you." - if yes?("Would you like me to create an OpenShift app for you now in this repo?") - puts "Okay, this may take a moment..." - puts `#{cmd}` - - git_config = capture("git config --list -f tmp-huginn/.git/config").split("\n") - git_config.grep(/^rhc\./).each do |line| - path, value = line.split('=') - puts `git config #{path} #{value}` - end - - url = git_config.grep(/^remote\.origin\.url/).first.split('=').last - puts "Adding remote #{url}" - puts `git remote add openshift #{url}` - - puts "Removing tmp OpenShift repo" - puts `rm -rf ./tmp-huginn` - - puts "Updating git" - puts `git fetch openshift` - - info = capture("rhc app show") - just_made = true - else - puts "Okay, exiting so you can do it." - exit 0 - end -elsif info =~ /Application '.*?' not found/ - puts "It looks like you've deleted your OpenShift app. If that's the case, you should" - puts "edit .git/config and remove the sections under [rhc] and under [remote \"openshift\"]." - exit 1 -end - -app_name, app_url = info.scan(/^([\w\d]+) @ https?:\/\/([^\/ ]+)/i).flatten -confirm_app_name app_name unless just_made -grab_openshift_config! -print_config -set_defaults! - -first_time = mode =~ /^first/i -unless $config['DOMAIN'] - set_value 'DOMAIN', app_url, force: false - first_time = true -end - -set_value 'BUNDLE_WITHOUT', 'development:test' - -puts -puts "To setup outbound email, we suggest using Gmail. See the 'Outgoing email settings' section in .env.example." -puts "You'll need to set those environment variables in OpenShift using 'rhc env set VARIABLE=VALUE'" -puts - -branch = capture("git rev-parse --abbrev-ref HEAD") -if first_time || yes?("Should I push your current branch (#{branch}) to OpenShift?", default: :yes) - puts "This may take a moment..." - puts capture("git push openshift #{branch}:master -f") -end - -if first_time - puts "Restarting..." - puts capture("rhc app restart") - puts capture("rhc cartridge restart foreman") - puts "Done!" - puts - puts - puts "I can make an admin user on your new Huginn instance and setup some example Agents." - if yes?("Should I create a new admin user and some example Agents?", default: :yes) - done = false - while !done - seed_email = nag "Okay, what is your email address?" - seed_username = nag "And what username would you like to login as?" - seed_password = nag "Finally, what password would you like to use?", noecho: true - puts "\nJust a moment..." - - result = capture("rhc ssh huginn 'cd $OPENSHIFT_REPO_DIR && GEM_HOME=$RVM_GEM_HOME bundle exec rake db:seed RAILS_ENV=production SEED_EMAIL=#{seed_email} SEED_USERNAME=#{seed_username} SEED_PASSWORD=#{seed_password}'") - puts result - if result =~ /Validation failed/ - puts "ERROR:" - puts - puts result - puts - else - done = true - end - end - puts - puts - puts "Okay, you should be all set! Visit http://#{app_url} and login as '#{seed_username}' with your password." - puts - puts "If you'd like to make more users, you can visit http://#{app_url}/users/sign_up and use the invitation code:" - else - puts - puts "Visit https://#{app_url}/users/sign_up and use the invitation code shown below:" - end - puts - puts "\t#{$config['INVITATION_CODE']}" - puts - puts "We recommend that you read https://github.com/cantino/huginn/wiki/Run-Huginn-for-free-on-OpenShift and setup Pingdom to keep your app awake!" -end - -puts -puts "Done!" diff --git a/openshift/templates/huginn-mysql.json b/openshift/templates/huginn-mysql.json new file mode 100644 index 00000000..d7613ed3 --- /dev/null +++ b/openshift/templates/huginn-mysql.json @@ -0,0 +1,630 @@ +{ + "kind": "Template", + "apiVersion": "v1", + "metadata": { + "name": "huginn-mysql-persistent", + "annotations": { + "openshift.io/display-name": "Huginn + MySQL (Persistent)", + "description": "A Huginn deployment with a MySQL database. For more information, see https://github.com/huginn/huginn.", + "tags": "quickstart,ruby,huginn", + "iconClass": "icon-huginn" + } + }, + "message": "The following service(s) have been created in your project: ${NAME}, ${DATABASE_SERVICE_NAME}. Visit https://${NAME}-YOUR_PROJECT_NAME.${ROUTER_SHARD}.${CLUSTER_NAME}.openshiftapps.com and login as '${HUGINN_SEED_USERNAME}' with your password. If you'd like to make more users, you can visit https://${NAME}-YOUR_PROJECT_NAME.${ROUTER_SHARD}.${CLUSTER_NAME}.openshiftapps.com/users/sign_up and use the invitation code: ${HUGINN_INVITATION_CODE}\n\nFor more information, see https://github.com/huginn/huginn.", + "labels": { + "template": "huginn-mysql-persistent" + }, + "objects": [{ + "kind": "Secret", + "apiVersion": "v1", + "metadata": { + "name": "${NAME}" + }, + "stringData" : { + "databaseName" : "${DATABASE_NAME}", + "databaseUser" : "${DATABASE_USER}", + "databasePassword" : "${DATABASE_PASSWORD}", + "seedUser" : "${HUGINN_SEED_USERNAME}", + "seedPassword" : "${HUGINN_SEED_PASSWORD}", + "seedEmail" : "${HUGINN_SEED_EMAIL}", + "smtpDomain" : "${HUGINN_SMTP_DOMAIN}", + "smtpUser" : "${HUGINN_SMTP_USER_NAME}", + "smtpPassword" : "${HUGINN_SMTP_PASSWORD}", + "smtpServer" : "${HUGINN_SMTP_SERVER}" + } + }, { + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "${NAME}", + "annotations": { + "description": "Exposes and load balances the application pods", + "service.alpha.openshift.io/dependencies": "[{\"name\": \"${DATABASE_SERVICE_NAME}\", \"kind\": \"Service\"}]" + } + }, + "spec": { + "ports": [{ + "name": "web", + "port": 8080, + "targetPort": 8080 + }], + "selector": { + "name": "${NAME}" + } + } + }, { + "kind": "Route", + "apiVersion": "v1", + "metadata": { + "name": "${NAME}" + }, + "spec": { + "host": "${APPLICATION_DOMAIN}", + "tls": { + "insecureEdgeTerminationPolicy": "Redirect", + "termination": "edge" + }, + "to": { + "kind": "Service", + "name": "${NAME}" + } + } + }, { + "kind": "ImageStream", + "apiVersion": "v1", + "metadata": { + "name": "${NAME}", + "annotations": { + "description": "Keeps track of changes in the application image" + } + } + }, { + "kind": "BuildConfig", + "apiVersion": "v1", + "metadata": { + "name": "${NAME}", + "annotations": { + "description": "Defines how to build the application" + } + }, + "spec": { + "source": { + "type": "Git", + "git": { + "uri": "${SOURCE_REPOSITORY_URL}", + "ref": "${SOURCE_REPOSITORY_REF}" + }, + "contextDir": "${CONTEXT_DIR}" + }, + "strategy": { + "type": "Source", + "sourceStrategy": { + "from": { + "kind": "ImageStreamTag", + "namespace": "${NAMESPACE}", + "name": "ruby:2.3" + }, + "env": [{ + "name": "APP_SECRET_TOKEN", + "value": "${HUGINN_APP_SECRET}" + }, { + "name": "DATABASE_ADAPTER", + "value": "${DATABASE_ADAPTER}" + }, { + "name": "LC_ALL", + "value": "en_US.UTF-8" + }, { + "name": "ON_HEROKU", + "value": "true" + }] + } + }, + "output": { + "to": { + "kind": "ImageStreamTag", + "name": "${NAME}:latest" + } + }, + "triggers": [{ + "type": "ImageChange" + }, { + "type": "ConfigChange" + }, { + "type": "GitHub", + "github": { + "secret": "${GITHUB_WEBHOOK_SECRET}" + } + }] + } + }, { + "kind": "PersistentVolumeClaim", + "apiVersion": "v1", + "metadata": { + "name": "${DATABASE_SERVICE_NAME}" + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "${VOLUME_CAPACITY}" + } + } + } + }, { + "kind": "DeploymentConfig", + "apiVersion": "v1", + "metadata": { + "name": "${NAME}", + "annotations": { + "description": "Defines how to deploy the application server" + } + }, + "spec": { + "strategy": { + "type": "Recreate" + }, + "triggers": [{ + "type": "ImageChange", + "imageChangeParams": { + "automatic": true, + "containerNames": [ + "huginn-mysql-persistent" + ], + "from": { + "kind": "ImageStreamTag", + "name": "${NAME}:latest" + } + } + }, { + "type": "ConfigChange" + }], + "replicas": 1, + "selector": { + "name": "${NAME}" + }, + "template": { + "metadata": { + "name": "${NAME}", + "labels": { + "name": "${NAME}" + } + }, + "spec": { + "containers": [{ + "name": "huginn-mysql-persistent", + "image": "${NAME}", + "ports": [{ + "containerPort": 8080 + }], + "readinessProbe": { + "timeoutSeconds": 3, + "initialDelaySeconds": 3, + "httpGet": { + "path": "/", + "port": 8080 + } + }, + "livenessProbe": { + "timeoutSeconds": 3, + "initialDelaySeconds": 30, + "httpGet": { + "path": "/", + "port": 8080 + } + }, + "env": [{ + "name": "SEED_USERNAME", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "seedUser" + } + } + }, { + "name": "SEED_PASSWORD", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "seedPassword" + } + } + }, { + "name": "SEED_EMAIL", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "seedEmail" + } + } + }, { + "name": "INVITATION_CODE", + "value": "${HUGINN_INVITATION_CODE}" + }, { + "name": "SMTP_DOMAIN", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "smtpDomain" + } + } + }, { + "name": "SMTP_USER_NAME", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "smtpUser" + } + } + }, { + "name": "SMTP_PASSWORD", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "smtpPassword" + } + } + }, { + "name": "SMTP_SERVER", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "smtpServer" + } + } + }, { + "name": "EMAIL_FROM_ADDRESS", + "value": "${HUGINN_EMAIL_FROM_ADDRESS}" + }, { + "name": "APPLICATION_DOMAIN", + "value": "${APPLICATION_DOMAIN}" + }, { + "name": "RAILS_ENV", + "value": "${HUGINN_RAILS_ENV}" + }, { + "name": "OPCACHE_REVALIDATE_FREQ", + "value": "${OPCACHE_REVALIDATE_FREQ}" + }, { + "name": "DATABASE_NAME", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "databaseName" + } + } + }, { + "name": "DATABASE_USERNAME", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "databaseUser" + } + } + }, { + "name": "DATABASE_PASSWORD", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "databasePassword" + } + } + }, { + "name": "DATABASE_HOST", + "value": "${DATABASE_SERVICE_NAME}_SERVICE_HOST" + }, { + "name": "DATABASE_PORT", + "value": "${DATABASE_SERVICE_NAME}_SERVICE_PORT" + }, { + "name": "DATABASE_ENCODING", + "value": "utf8mb4" + }, { + "name": "DO_NOT_CREATE_DATABASE", + "value": "1" + }, { + "name": "RAILS_SERVE_STATIC_FILES", + "value": "1" + }, { + "name": "WORKER_CMD", + "value": "unicorn -c ./deployment/heroku/unicorn.rb --listen 0.0.0.0:8080" + }], + "resources": { + "limits": { + "memory": "${MEMORY_LIMIT}" + } + } + }] + } + } + } + }, { + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "${DATABASE_SERVICE_NAME}", + "annotations": { + "description": "Exposes the database server" + } + }, + "spec": { + "ports": [{ + "name": "mysql", + "port": 3306, + "targetPort": 3306 + }], + "selector": { + "name": "${DATABASE_SERVICE_NAME}" + } + } + }, { + "kind": "DeploymentConfig", + "apiVersion": "v1", + "metadata": { + "name": "${DATABASE_SERVICE_NAME}", + "annotations": { + "description": "Defines how to deploy the database" + } + }, + "spec": { + "strategy": { + "type": "Recreate" + }, + "triggers": [{ + "type": "ImageChange", + "imageChangeParams": { + "automatic": true, + "containerNames": [ + "mysql" + ], + "from": { + "kind": "ImageStreamTag", + "namespace": "${NAMESPACE}", + "name": "mysql:5.7" + } + } + }, { + "type": "ConfigChange" + }], + "replicas": 1, + "selector": { + "name": "${DATABASE_SERVICE_NAME}" + }, + "template": { + "metadata": { + "name": "${DATABASE_SERVICE_NAME}", + "labels": { + "name": "${DATABASE_SERVICE_NAME}" + } + }, + "spec": { + "containers": [{ + "name": "mysql", + "image": "mysql", + "ports": [{ + "containerPort": 3306 + }], + "readinessProbe": { + "timeoutSeconds": 1, + "initialDelaySeconds": 5, + "exec": { + "command": ["/bin/sh", "-i", "-c", "MYSQL_PWD='${DATABASE_PASSWORD}' mysql -h 127.0.0.1 -u ${DATABASE_USER} -D ${DATABASE_NAME} -e 'SELECT 1'"] + } + }, + "livenessProbe": { + "timeoutSeconds": 1, + "initialDelaySeconds": 30, + "tcpSocket": { + "port": 3306 + } + }, + "env": [{ + "name": "MYSQL_DATABASE", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "databaseName" + } + } + }, { + "name": "MYSQL_USER", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "databaseUser" + } + } + }, { + "name": "MYSQL_PASSWORD", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "databasePassword" + } + } + }], + "resources": { + "limits": { + "memory": "${MEMORY_MYSQL_LIMIT}" + } + }, + "volumeMounts": [{ + "name": "${DATABASE_SERVICE_NAME}-data", + "mountPath": "/var/lib/mysql/data" + }] + }], + "volumes": [{ + "name": "${DATABASE_SERVICE_NAME}-data", + "persistentVolumeClaim": { + "claimName": "${DATABASE_SERVICE_NAME}" + } + }] + } + } + } + }], + "parameters": [{ + "name": "NAME", + "displayName": "Name", + "description": "The name assigned to all of the frontend objects defined in this template.", + "required": true, + "value": "huginn" + }, { + "name": "HUGINN_SEED_USERNAME", + "displayName": "Huginn SEED_USERNAME", + "description": "Account ID for the admin user.", + "value": "admin", + "required": true + }, { + "name": "HUGINN_SEED_PASSWORD", + "displayName": "Huginn SEED_PASSWORD", + "description": "Password for the admin user.", + "value": "password", + "required": true + }, { + "name": "HUGINN_SEED_EMAIL", + "displayName": "Huginn SEED_EMAIL", + "description": "Email for the admin user.", + "value": "huginn@example.com", + "required": true + }, { + "name": "HUGINN_INVITATION_CODE", + "displayName": "Huginn INVITATION_CODE", + "description": "If you'd like to invite more users, give them this invitation code.", + "generate": "expression", + "from": "[\\w]{10}" + }, { + "name": "HUGINN_SMTP_DOMAIN", + "displayName": "Huginn SMTP_DOMAIN", + "description": "Domain for outbound emails.", + "value": "example.com", + "required": true + }, { + "name": "HUGINN_SMTP_USER_NAME", + "displayName": "Huginn SMTP_USER_NAME", + "description": "SMTP user name.", + "value": "huginn@example.com", + "required": true + }, { + "name": "HUGINN_SMTP_PASSWORD", + "displayName": "Huginn SMTP_PASSWORD", + "description": "SMTP password.", + "value": "somepassword", + "required": true + }, { + "name": "HUGINN_SMTP_SERVER", + "displayName": "Huginn SMTP_SERVER", + "description": "SMTP server address.", + "value": "smtp.example.com", + "required": true + }, { + "name": "HUGINN_EMAIL_FROM_ADDRESS", + "displayName": "Huginn EMAIL_FROM_ADDRESS", + "description": "The address from which system emails will appear to be sent.", + "value": "huginn@example.com", + "required": true + }, { + "name": "HUGINN_APP_SECRET", + "displayName": "Huginn APP_SECRET_TOKEN", + "description": "Set this to a 64 character random string (e.g., from 'rake secret').", + "generate": "expression", + "from": "[\\w]{64}" + }, { + "name": "SOURCE_REPOSITORY_URL", + "displayName": "Git Repository URL", + "description": "The URL of the repository with your application source code.", + "value": "https://github.com/huginn/huginn.git", + "required": true + }, { + "name": "SOURCE_REPOSITORY_REF", + "displayName": "Git Reference", + "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch." + }, { + "name": "CONTEXT_DIR", + "displayName": "Context Directory", + "description": "Set this to the relative path to your project if it is not in the root of your repository." + }, { + "name": "GITHUB_WEBHOOK_SECRET", + "displayName": "GitHub Webhook Secret", + "description": "A secret string used to configure the GitHub webhook.", + "generate": "expression", + "from": "[a-zA-Z0-9]{40}" + }, { + "displayName": "Cluster Name", + "name": "CLUSTER_NAME", + "description": "The name of your current OpenShift cluster (console.CLUSTER_NAME.openshift.com).", + "value": "starter-us-west-2", + "required": true + }, { + "displayName": "Router Shard", + "name": "ROUTER_SHARD", + "description": "The router shard used by routes in your current OpenShift cluster (http://PROJECT_NAME-APPLICATION_NAME.ROUTER_SHARD.CLUSTER_NAME.openshiftapps.com/).", + "value": "7e14", + "required": true + }, { + "name": "APPLICATION_DOMAIN", + "displayName": "Application Hostname", + "description": "The exposed hostname that will route to the Huginn service, if left blank a value will be defaulted.", + "value": "" + }, { + "name": "NAMESPACE", + "displayName": "Namespace", + "description": "The OpenShift Namespace where the ImageStream resides.", + "required": true, + "value": "openshift" + }, { + "name": "DATABASE_SERVICE_NAME", + "displayName": "Database Service Name", + "value": "mysql", + "required": true + }, { + "name": "HUGINN_RAILS_ENV", + "displayName": "Huginn Application Environment", + "description": "Determines the 'environment' your application is currently.", + "value": "production", + "required": true + }, { + "name": "OPCACHE_REVALIDATE_FREQ", + "displayName": "OPcache Revalidation Frequency", + "description": "How often to check script timestamps for updates, in seconds. 0 will result in OPcache checking for updates on every request.", + "value": "0" + }, { + "name": "MEMORY_LIMIT", + "displayName": "Memory Limit", + "description": "Maximum amount of memory the Huginn container can use.", + "value": "512Mi", + "required": true + }, { + "name": "MEMORY_MYSQL_LIMIT", + "displayName": "Memory Limit (MySQL)", + "description": "Maximum amount of memory the MySQL container can use.", + "value": "512Mi", + "required": true + }, { + "name": "VOLUME_CAPACITY", + "displayName": "Volume Capacity", + "description": "Volume space available for data, e.g. 512Mi, 2Gi", + "value": "1Gi", + "required": true + }, { + "name": "DATABASE_ADAPTER", + "displayName": "Database Engine", + "description": "Database engine: mysql2 (default) or postgresql.", + "value": "mysql2", + "required": true + }, { + "name": "DATABASE_NAME", + "displayName": "Database Name", + "generate": "expression", + "from": "[a-zA-Z0-9]{6}" + }, { + "name": "DATABASE_USER", + "displayName": "Database User", + "generate": "expression", + "from": "[a-zA-Z0-9]{6}" + }, { + "name": "DATABASE_PASSWORD", + "displayName": "Database Password", + "generate": "expression", + "from": "[a-zA-Z0-9]{16}" + }] +} diff --git a/openshift/templates/huginn-postgresql.json b/openshift/templates/huginn-postgresql.json new file mode 100644 index 00000000..8eca8633 --- /dev/null +++ b/openshift/templates/huginn-postgresql.json @@ -0,0 +1,630 @@ +{ + "kind": "Template", + "apiVersion": "v1", + "metadata": { + "name": "huginn-pgsql-persistent", + "annotations": { + "openshift.io/display-name": "Huginn + PostgreSQL (Persistent)", + "description": "A Huginn deployment with a PostgreSQL database. For more information, see https://github.com/huginn/huginn.", + "tags": "quickstart,ruby,huginn", + "iconClass": "icon-huginn" + } + }, + "message": "The following service(s) have been created in your project: ${NAME}, ${DATABASE_SERVICE_NAME}. Visit https://${NAME}-YOUR_PROJECT_NAME.${ROUTER_SHARD}.${CLUSTER_NAME}.openshiftapps.com and login as '${HUGINN_SEED_USERNAME}' with your password. If you'd like to make more users, you can visit https://${NAME}-YOUR_PROJECT_NAME.${ROUTER_SHARD}.${CLUSTER_NAME}.openshiftapps.com/users/sign_up and use the invitation code: ${HUGINN_INVITATION_CODE}\n\nFor more information, see https://github.com/huginn/huginn.", + "labels": { + "template": "huginn-pgsql-persistent" + }, + "objects": [{ + "kind": "Secret", + "apiVersion": "v1", + "metadata": { + "name": "${NAME}" + }, + "stringData" : { + "databaseName" : "${DATABASE_NAME}", + "databaseUser" : "${DATABASE_USER}", + "databasePassword" : "${DATABASE_PASSWORD}", + "seedUser" : "${HUGINN_SEED_USERNAME}", + "seedPassword" : "${HUGINN_SEED_PASSWORD}", + "seedEmail" : "${HUGINN_SEED_EMAIL}", + "smtpDomain" : "${HUGINN_SMTP_DOMAIN}", + "smtpUser" : "${HUGINN_SMTP_USER_NAME}", + "smtpPassword" : "${HUGINN_SMTP_PASSWORD}", + "smtpServer" : "${HUGINN_SMTP_SERVER}" + } + }, { + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "${NAME}", + "annotations": { + "description": "Exposes and load balances the application pods", + "service.alpha.openshift.io/dependencies": "[{\"name\": \"${DATABASE_SERVICE_NAME}\", \"kind\": \"Service\"}]" + } + }, + "spec": { + "ports": [{ + "name": "web", + "port": 8080, + "targetPort": 8080 + }], + "selector": { + "name": "${NAME}" + } + } + }, { + "kind": "Route", + "apiVersion": "v1", + "metadata": { + "name": "${NAME}" + }, + "spec": { + "host": "${APPLICATION_DOMAIN}", + "tls": { + "insecureEdgeTerminationPolicy": "Redirect", + "termination": "edge" + }, + "to": { + "kind": "Service", + "name": "${NAME}" + } + } + }, { + "kind": "ImageStream", + "apiVersion": "v1", + "metadata": { + "name": "${NAME}", + "annotations": { + "description": "Keeps track of changes in the application image" + } + } + }, { + "kind": "BuildConfig", + "apiVersion": "v1", + "metadata": { + "name": "${NAME}", + "annotations": { + "description": "Defines how to build the application" + } + }, + "spec": { + "source": { + "type": "Git", + "git": { + "uri": "${SOURCE_REPOSITORY_URL}", + "ref": "${SOURCE_REPOSITORY_REF}" + }, + "contextDir": "${CONTEXT_DIR}" + }, + "strategy": { + "type": "Source", + "sourceStrategy": { + "from": { + "kind": "ImageStreamTag", + "namespace": "${NAMESPACE}", + "name": "ruby:2.3" + }, + "env": [{ + "name": "APP_SECRET_TOKEN", + "value": "${HUGINN_APP_SECRET}" + }, { + "name": "DATABASE_ADAPTER", + "value": "${DATABASE_ADAPTER}" + }, { + "name": "LC_ALL", + "value": "en_US.UTF-8" + }, { + "name": "ON_HEROKU", + "value": "true" + }] + } + }, + "output": { + "to": { + "kind": "ImageStreamTag", + "name": "${NAME}:latest" + } + }, + "triggers": [{ + "type": "ImageChange" + }, { + "type": "ConfigChange" + }, { + "type": "GitHub", + "github": { + "secret": "${GITHUB_WEBHOOK_SECRET}" + } + }] + } + }, { + "kind": "PersistentVolumeClaim", + "apiVersion": "v1", + "metadata": { + "name": "${DATABASE_SERVICE_NAME}" + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "${VOLUME_CAPACITY}" + } + } + } + }, { + "kind": "DeploymentConfig", + "apiVersion": "v1", + "metadata": { + "name": "${NAME}", + "annotations": { + "description": "Defines how to deploy the application server" + } + }, + "spec": { + "strategy": { + "type": "Recreate" + }, + "triggers": [{ + "type": "ImageChange", + "imageChangeParams": { + "automatic": true, + "containerNames": [ + "huginn-pgsql-persistent" + ], + "from": { + "kind": "ImageStreamTag", + "name": "${NAME}:latest" + } + } + }, { + "type": "ConfigChange" + }], + "replicas": 1, + "selector": { + "name": "${NAME}" + }, + "template": { + "metadata": { + "name": "${NAME}", + "labels": { + "name": "${NAME}" + } + }, + "spec": { + "containers": [{ + "name": "huginn-pgsql-persistent", + "image": "${NAME}", + "ports": [{ + "containerPort": 8080 + }], + "readinessProbe": { + "timeoutSeconds": 3, + "initialDelaySeconds": 3, + "httpGet": { + "path": "/", + "port": 8080 + } + }, + "livenessProbe": { + "timeoutSeconds": 3, + "initialDelaySeconds": 30, + "httpGet": { + "path": "/", + "port": 8080 + } + }, + "env": [{ + "name": "SEED_USERNAME", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "seedUser" + } + } + }, { + "name": "SEED_PASSWORD", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "seedPassword" + } + } + }, { + "name": "SEED_EMAIL", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "seedEmail" + } + } + }, { + "name": "INVITATION_CODE", + "value": "${HUGINN_INVITATION_CODE}" + }, { + "name": "SMTP_DOMAIN", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "smtpDomain" + } + } + }, { + "name": "SMTP_USER_NAME", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "smtpUser" + } + } + }, { + "name": "SMTP_PASSWORD", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "smtpPassword" + } + } + }, { + "name": "SMTP_SERVER", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "smtpServer" + } + } + }, { + "name": "EMAIL_FROM_ADDRESS", + "value": "${HUGINN_EMAIL_FROM_ADDRESS}" + }, { + "name": "APPLICATION_DOMAIN", + "value": "${APPLICATION_DOMAIN}" + }, { + "name": "RAILS_ENV", + "value": "${HUGINN_RAILS_ENV}" + }, { + "name": "OPCACHE_REVALIDATE_FREQ", + "value": "${OPCACHE_REVALIDATE_FREQ}" + }, { + "name": "DATABASE_NAME", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "databaseName" + } + } + }, { + "name": "DATABASE_USERNAME", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "databaseUser" + } + } + }, { + "name": "DATABASE_PASSWORD", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "databasePassword" + } + } + }, { + "name": "DATABASE_HOST", + "value": "${DATABASE_SERVICE_NAME}_SERVICE_HOST" + }, { + "name": "DATABASE_PORT", + "value": "${DATABASE_SERVICE_NAME}_SERVICE_PORT" + }, { + "name": "DATABASE_ENCODING", + "value": "utf8" + }, { + "name": "DO_NOT_CREATE_DATABASE", + "value": "1" + }, { + "name": "RAILS_SERVE_STATIC_FILES", + "value": "1" + }, { + "name": "WORKER_CMD", + "value": "unicorn -c ./deployment/heroku/unicorn.rb --listen 0.0.0.0:8080" + }], + "resources": { + "limits": { + "memory": "${MEMORY_LIMIT}" + } + } + }] + } + } + } + }, { + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "${DATABASE_SERVICE_NAME}", + "annotations": { + "description": "Exposes the database server" + } + }, + "spec": { + "ports": [{ + "name": "pgsql", + "port": 5432, + "targetPort": 5432 + }], + "selector": { + "name": "${DATABASE_SERVICE_NAME}" + } + } + }, { + "kind": "DeploymentConfig", + "apiVersion": "v1", + "metadata": { + "name": "${DATABASE_SERVICE_NAME}", + "annotations": { + "description": "Defines how to deploy the database" + } + }, + "spec": { + "strategy": { + "type": "Recreate" + }, + "triggers": [{ + "type": "ImageChange", + "imageChangeParams": { + "automatic": true, + "containerNames": [ + "postgresql" + ], + "from": { + "kind": "ImageStreamTag", + "namespace": "${NAMESPACE}", + "name": "postgresql:9.5" + } + } + }, { + "type": "ConfigChange" + }], + "replicas": 1, + "selector": { + "name": "${DATABASE_SERVICE_NAME}" + }, + "template": { + "metadata": { + "name": "${DATABASE_SERVICE_NAME}", + "labels": { + "name": "${DATABASE_SERVICE_NAME}" + } + }, + "spec": { + "containers": [{ + "name": "postgresql", + "image": "postgresql", + "ports": [{ + "containerPort": 5432 + }], + "readinessProbe": { + "timeoutSeconds": 1, + "initialDelaySeconds": 5, + "exec": { + "command": ["/bin/sh", "-i", "-c", "psql -h 127.0.0.1 -U ${DATABASE_USER} -q -d ${DATABASE_NAME} -c 'SELECT 1'"] + } + }, + "livenessProbe": { + "timeoutSeconds": 1, + "initialDelaySeconds": 30, + "tcpSocket": { + "port": 5432 + } + }, + "env": [{ + "name": "POSTGRESQL_DATABASE", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "databaseName" + } + } + }, { + "name": "POSTGRESQL_USER", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "databaseUser" + } + } + }, { + "name": "POSTGRESQL_PASSWORD", + "valueFrom": { + "secretKeyRef" : { + "name" : "${NAME}", + "key" : "databasePassword" + } + } + }], + "resources": { + "limits": { + "memory": "${MEMORY_POSTGRESQL_LIMIT}" + } + }, + "volumeMounts": [{ + "name": "${DATABASE_SERVICE_NAME}-data", + "mountPath": "/var/lib/pgsql/data" + }] + }], + "volumes": [{ + "name": "${DATABASE_SERVICE_NAME}-data", + "persistentVolumeClaim": { + "claimName": "${DATABASE_SERVICE_NAME}" + } + }] + } + } + } + }], + "parameters": [{ + "name": "NAME", + "displayName": "Name", + "description": "The name assigned to all of the frontend objects defined in this template.", + "required": true, + "value": "huginn" + }, { + "name": "HUGINN_SEED_USERNAME", + "displayName": "Huginn SEED_USERNAME", + "description": "Account ID for the admin user.", + "value": "admin", + "required": true + }, { + "name": "HUGINN_SEED_PASSWORD", + "displayName": "Huginn SEED_PASSWORD", + "description": "Password for the admin user.", + "value": "password", + "required": true + }, { + "name": "HUGINN_SEED_EMAIL", + "displayName": "Huginn SEED_EMAIL", + "description": "Email for the admin user.", + "value": "huginn@example.com", + "required": true + }, { + "name": "HUGINN_INVITATION_CODE", + "displayName": "Huginn INVITATION_CODE", + "description": "If you'd like to invite more users, give them this invitation code.", + "generate": "expression", + "from": "[\\w]{10}" + }, { + "name": "HUGINN_SMTP_DOMAIN", + "displayName": "Huginn SMTP_DOMAIN", + "description": "Domain for outbound emails.", + "value": "example.com", + "required": true + }, { + "name": "HUGINN_SMTP_USER_NAME", + "displayName": "Huginn SMTP_USER_NAME", + "description": "SMTP user name.", + "value": "huginn@example.com", + "required": true + }, { + "name": "HUGINN_SMTP_PASSWORD", + "displayName": "Huginn SMTP_PASSWORD", + "description": "SMTP password.", + "value": "somepassword", + "required": true + }, { + "name": "HUGINN_SMTP_SERVER", + "displayName": "Huginn SMTP_SERVER", + "description": "SMTP server address.", + "value": "smtp.example.com", + "required": true + }, { + "name": "HUGINN_EMAIL_FROM_ADDRESS", + "displayName": "Huginn EMAIL_FROM_ADDRESS", + "description": "The address from which system emails will appear to be sent.", + "value": "huginn@example.com", + "required": true + }, { + "name": "HUGINN_APP_SECRET", + "displayName": "Huginn APP_SECRET_TOKEN", + "description": "Set this to a 64 character random string (e.g., from 'rake secret').", + "generate": "expression", + "from": "[\\w]{64}" + }, { + "name": "SOURCE_REPOSITORY_URL", + "displayName": "Git Repository URL", + "description": "The URL of the repository with your application source code.", + "value": "https://github.com/huginn/huginn.git", + "required": true + }, { + "name": "SOURCE_REPOSITORY_REF", + "displayName": "Git Reference", + "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch." + }, { + "name": "CONTEXT_DIR", + "displayName": "Context Directory", + "description": "Set this to the relative path to your project if it is not in the root of your repository." + }, { + "name": "GITHUB_WEBHOOK_SECRET", + "displayName": "GitHub Webhook Secret", + "description": "A secret string used to configure the GitHub webhook.", + "generate": "expression", + "from": "[a-zA-Z0-9]{40}" + }, { + "displayName": "Cluster Name", + "name": "CLUSTER_NAME", + "description": "The name of your current OpenShift cluster (console.CLUSTER_NAME.openshift.com).", + "value": "starter-us-west-2", + "required": true + }, { + "displayName": "Router Shard", + "name": "ROUTER_SHARD", + "description": "The router shard used by routes in your current OpenShift cluster (http://PROJECT_NAME-APPLICATION_NAME.ROUTER_SHARD.CLUSTER_NAME.openshiftapps.com/).", + "value": "7e14", + "required": true + }, { + "name": "APPLICATION_DOMAIN", + "displayName": "Application Hostname", + "description": "The exposed hostname that will route to the Huginn service, if left blank a value will be defaulted.", + "value": "" + }, { + "name": "NAMESPACE", + "displayName": "Namespace", + "description": "The OpenShift Namespace where the ImageStream resides.", + "required": true, + "value": "openshift" + }, { + "name": "DATABASE_SERVICE_NAME", + "displayName": "Database Service Name", + "value": "postgresql", + "required": true + }, { + "name": "HUGINN_RAILS_ENV", + "displayName": "Huginn Application Environment", + "description": "Determines the 'environment' your application is currently.", + "value": "production", + "required": true + }, { + "name": "OPCACHE_REVALIDATE_FREQ", + "displayName": "OPcache Revalidation Frequency", + "description": "How often to check script timestamps for updates, in seconds. 0 will result in OPcache checking for updates on every request.", + "value": "0" + }, { + "name": "MEMORY_LIMIT", + "displayName": "Memory Limit", + "description": "Maximum amount of memory the Huginn container can use.", + "value": "512Mi", + "required": true + }, { + "name": "MEMORY_POSTGRESQL_LIMIT", + "displayName": "Memory Limit (PostgreSQL)", + "description": "Maximum amount of memory the PostgreSQL container can use.", + "value": "512Mi", + "required": true + }, { + "name": "VOLUME_CAPACITY", + "displayName": "Volume Capacity", + "description": "Volume space available for data, e.g. 512Mi, 2Gi", + "value": "1Gi", + "required": true + }, { + "name": "DATABASE_ADAPTER", + "displayName": "Database Engine", + "description": "Database engine: mysql2 or postgresql (default).", + "value": "postgresql", + "required": true + }, { + "name": "DATABASE_NAME", + "displayName": "Database Name", + "generate": "expression", + "from": "[a-zA-Z0-9]{6}" + }, { + "name": "DATABASE_USER", + "displayName": "Database User", + "generate": "expression", + "from": "[a-zA-Z0-9]{6}" + }, { + "name": "DATABASE_PASSWORD", + "displayName": "Database Password", + "generate": "expression", + "from": "[a-zA-Z0-9]{16}" + }] +}