tvl-depot/users/grfn/bbbg
Griffin Smith acd4728661 fix(grfn/bbbg): Fill in the right organizer role ID
I figured this out by opening discord in my browser, navigating to the
"roles" section of the server settings page, and looking at the API
response for
https://discord.com/api/v9/guilds/<guild-id>/roles/member-counts - the
Organizer role has a unique member count, so I could sniff out its role
ID by looking at the JSON. There *might* be a way in the API to do this,
but I couldn't find it in the docs.

Change-Id: Idac72886b12d53a570b473b55ef0cf7f965d37f2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5116
Reviewed-by: grfn <grfn@gws.fyi>
Autosubmit: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2022-01-29 17:54:12 +00:00
..
.clj-kondo feat(grfn/bbbg): Init 2021-12-13 21:45:09 -05:00
env feat(grfn/bbbg): Init 2021-12-13 21:45:09 -05:00
resources feat(grfn/bbbg): Add delete event button 2022-01-20 14:32:36 +00:00
src/bbbg fix(grfn/bbbg): Fill in the right organizer role ID 2022-01-29 17:54:12 +00:00
test/bbbg/meetup feat(grfn/bbbg): Allow importing event attendees 2021-12-24 17:43:28 +00:00
.envrc feat(grfn/bbbg): Init 2021-12-13 21:45:09 -05:00
.gitignore feat(grfn/bbbg): Init 2021-12-13 21:45:09 -05:00
arion-compose.nix feat(grfn/bbbg): Init 2021-12-13 21:45:09 -05:00
arion-pkgs.nix feat(grfn/bbbg): Init 2021-12-13 21:45:09 -05:00
default.nix feat(grfn/bbbg): Production deployment 2021-12-27 03:46:27 +00:00
deps.edn feat(grfn/bbbg): Update (almost) all deps 2021-12-27 04:08:31 +00:00
deps.nix feat(grfn/bbbg): Update (almost) all deps 2021-12-27 04:08:31 +00:00
Makefile feat(grfn/bbbg): Init 2021-12-13 21:45:09 -05:00
module.nix fix(grfn/bbbg): Configure web base url 2021-12-27 03:52:29 +00:00
pom.xml feat(grfn/bbbg): Init 2021-12-13 21:45:09 -05:00
README.org feat(grfn/bbbg): Add info on running the app 2022-01-29 17:52:11 +00:00
shell.nix feat(grfn/bbbg): Production deployment 2021-12-27 03:46:27 +00:00
tf.nix fix: address warnings for renamed security.acme.email option 2022-01-04 17:35:52 +00:00

Brooklyn-Based Board Gaming Signup Sheet

This directory contains a small web application that acts as a signup sheet and attendee tracking system for my local board gaming meetup.

Development

Installing dependencies

With Nix + Docker ("blessed way")

Prerequisites:

From this directory in a full checkout of depot, run the following commands to install all development dependencies:

$ pwd
/path/to/depot/users/grfn/bbbg
$ direnv allow
$ lorri watch --once # Wait for a single nix shell build

Then, to run a docker container with the development database:

$ pwd
/path/to/depot/users/grfn/bbbg
$ arion up -d

Choose-your-own-adventure

Note that the authoritative source for dev dependencies is the shell.nix file in this directory - those may diverge from what's written here, and if so follow those versions rather than these.

  • Install the clojure command-line tools, with openjdk 11
  • Install and run a postgresql 12 database, with:

    • A user with superuser priveleges, the username bbbg and the password password
    • A database called bbbg owned by that user.
  • Export the following environment variables in a context visible by whatever method you use to run the application:

    • PGHOST=localhost
    • PGUSER=bbbg
    • PGDATABASE=bbbg
    • PGPASSWORD=bbbg

Running the application

Before running the app, you'll need an oauth2 client-id and client secret for a Discord app. The application can either load those from a pass password store, or read them from plaintext files in a directory. In either case, they should be accessible at the paths bbbg/discord-client-id and bbbg/discord-client-secret respectively.

From the command line

$ clj -A:dev
Clojure 1.11.0-alpha3
user=> (require 'bbbg.core)
nil
user=> ;; Optionally, if you're using a directory with plaintext files for the discord client ID and client secret:
user=> (bbbg.util.dev-secrets/set-backend! [:dir "/path/to/that/directory"])
user=> (bbbg.core/run-dev)
#<SystemMap>
user=> (bbbg.db/migrate! (:db bbbg.core/system))
11:57:26.536 [main] INFO  migratus.core - Starting migrations {  }
11:57:26.538 [main] INFO  com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting... {  }
11:57:26.883 [main] INFO  com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection com.impossibl.postgres.jdbc.PGDirectConnection@3cae770e {  }
11:57:26.884 [main] INFO  com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed. {  }
11:57:26.923 [main] INFO  migratus.core - Ending migrations {  }
nil

This will run a web server for the application listening at http://localhost:8888

In Emacs, with CIDER + direnv

Open //users/grfn/bbbg/src/bbbg/core.clj in a buffer, then follow the instructions at the end of the file

Deployment

With nix+terraform

Deployment configuration is located in the tf.nix file, which is currently tightly coupled to my own infrastructure and AWS account but could hypothetically be adjusted to be general-purpose.

To deploy a new version of the application, after following "installing dependencies" above, run the following command in a context with ec2 credentials available:

$ terraform apply

The current deploy configuration includes:

  • An ec2 instance running nixos, with a postgresql database and the bbbg application running as a service, behind nginx with an auto-renewing letsencrypt cert
  • The DNS A record for bbbg.gws.fyi pointing at that ec2 instance, in the cloudflare zone for gws.fyi

Otherwise

¯\_(ツ)_/¯

You'll need:

  • An uberjar for bbbg; the canonical way of building that is nix-build /path/to/depot -A users.grfn.bbbg.server-jar but I'm not sure how that works outside of nix
  • A postgresql database
  • Environment variables telling the app how to connect to that database. See config.systemd.services.bbbg-server.environment in module.nix for which env vars are currently being exported by the NixOS module that runs the production version of the app