Looking for public data from Hack Club? See AirBridge or Hack Club Bank API
The backend powering https://hackclub.com. Illustrated above by @maxwofford.
Install rbenv
brew install rbenv
Install bundler
gem install bundler -v 1.17.3
Run bundler
bundle install
Copy .env.example to .env
cp .env.example .env
Create and migrate database
bundle exec rake db:drop db:create db:migrate
Run the application
bin/rails s
Browse to localhost:3000
Copy .env file
cp .env.docker.example .env.docker
Run Docker
docker-compose build
docker-compose run web bundle install
#docker-compose run web yarn install --check-files
docker-compose run web bundle exec rails db:drop db:create db:migrate
docker-compose run --service-ports web bundle exec rails s -b 0.0.0.0 -p 3000
- Create a new Slack app on Slack
- Create one (and only one) bot user and set "Always Show My Bot as Online" to "On"
- Click "Event Subscriptions" on the sidebar in the left and set the request URL to
HOSTNAME/v1/hackbot/webhooks/events
, replacingHOSTNAME
with your actual hostname. - Subscribe to the following bot events:
message.channels
,message.im
,message.groups
,message.mpim
- Click "Interactive Messages" on the left sidebar and set the request URL to
HOSTNAME/v1/hackbot/webhooks/interactive_messages
, replacingHOSTNAME
with your actual hostname. - Manually go through the Oauth flow and POST
code
to/v1/hackbot/auth
This application depends on a few jobs running periodically in the background. Set this up using cron or a similar scheduler on your deployment of the application -- we use Heroku's scheduler in production.
rails heroku_scheduler:queue_update_hackbot_slack_username_job
hourlyrails heroku_scheduler:queue_record_slack_stats_job
dailyrails heroku_scheduler:queue_activate_clubs_job
dailyrails heroku_scheduler:queue_collect_projects_shipped_job
dailyrails heroku_scheduler:queue_schedule_leader_check_ins_job
dailyrails heroku_scheduler:queue_handle_spam_club_applications_job
every 10 minutesrails heroku_scheduler:queue_update_from_streak_job
hourlyrails heroku_scheduler:queue_close_check_ins_job
daily
We use Heroku for managing our deployment of this project and that brings along some special caveats. Specifically, we rely on multiple buildpacks.
Here are the buildpacks that need to be configured (they must be in the given order):
https://github.com/heroku/heroku-buildpack-activestorage-preview
https://github.com/heroku/heroku-buildpack-apt
heroku/ruby
Refer to https://devcenter.heroku.com/articles/buildpacks for instructions on configuring buildpacks.
We use Skylight to profile the performance of our backend in production. To use it, you must set SKYLIGHT_AUTHENTICATION
in the environment to the value that Skylight gives you.