2022-01-29 19:01:43 +01:00
|
|
|
# Brooklyn-Based Board Gaming signup sheet
|
|
|
|
|
2022-01-29 18:53:53 +01:00
|
|
|
This directory contains a small web application that acts as a signup
|
|
|
|
sheet and attendee tracking system for [my local board gaming
|
|
|
|
meetup](https://www.meetup.com/brooklyn-based-board-gaming/).
|
|
|
|
|
2022-01-29 19:01:43 +01:00
|
|
|
## Development
|
2022-01-29 18:53:53 +01:00
|
|
|
|
2022-01-29 19:01:43 +01:00
|
|
|
### Installing dependencies
|
2022-01-29 18:53:53 +01:00
|
|
|
|
2022-01-29 19:01:43 +01:00
|
|
|
#### With Nix + Docker ("blessed way")
|
2022-01-29 18:53:53 +01:00
|
|
|
|
|
|
|
Prerequisites:
|
|
|
|
|
|
|
|
- [Nix](https://nixos.org/)
|
|
|
|
- [lorri](https://github.com/nix-community/lorri)
|
|
|
|
- [Docker](https://www.docker.com/)
|
|
|
|
|
|
|
|
From this directory in a full checkout of depot, run the following
|
|
|
|
commands to install all development dependencies:
|
|
|
|
|
|
|
|
``` shell-session
|
|
|
|
$ pwd
|
2024-02-12 04:00:40 +01:00
|
|
|
/path/to/depot/users/aspen/bbbg
|
2022-01-29 18:53:53 +01:00
|
|
|
$ direnv allow
|
|
|
|
$ lorri watch --once # Wait for a single nix shell build
|
|
|
|
```
|
|
|
|
|
|
|
|
Then, to run a docker container with the development database:
|
|
|
|
|
|
|
|
``` shell-session
|
|
|
|
$ pwd
|
2024-02-12 04:00:40 +01:00
|
|
|
/path/to/depot/users/aspen/bbbg
|
2022-01-29 18:53:53 +01:00
|
|
|
$ arion up -d
|
|
|
|
```
|
|
|
|
|
2022-01-29 19:01:43 +01:00
|
|
|
#### Choose-your-own-adventure
|
2022-01-29 18:53:53 +01:00
|
|
|
|
2022-01-29 19:00:19 +01:00
|
|
|
Note that the **authoritative** source for dev dependencies is the `shell.nix`
|
|
|
|
file in this directory - those may diverge from what's written here; if so
|
|
|
|
follow those versions rather than these.
|
2022-01-29 18:53:53 +01:00
|
|
|
|
|
|
|
- Install the [clojure command-line
|
|
|
|
tools](https://clojure.org/guides/getting_started), 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`
|
|
|
|
|
2022-01-29 19:01:43 +01:00
|
|
|
### Running the application
|
2022-01-29 18:53:53 +01:00
|
|
|
|
2022-01-29 19:00:19 +01:00
|
|
|
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
|
2022-01-29 18:53:53 +01:00
|
|
|
[pass](https://www.passwordstore.org/) password store, or read them from
|
2022-01-29 19:00:19 +01:00
|
|
|
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.
|
2022-01-29 18:53:53 +01:00
|
|
|
|
2022-01-29 19:01:43 +01:00
|
|
|
#### From the command line
|
2022-01-29 18:53:53 +01:00
|
|
|
|
|
|
|
``` shell-session
|
|
|
|
$ 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)
|
2022-01-29 19:01:43 +01:00
|
|
|
##<SystemMap>
|
2022-01-29 18:53:53 +01:00
|
|
|
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>
|
|
|
|
|
2022-01-29 19:01:43 +01:00
|
|
|
#### In Emacs, with [CIDER](https://docs.cider.mx/cider/index.html) + [direnv](https://github.com/wbolster/emacs-direnv)
|
2022-01-29 18:53:53 +01:00
|
|
|
|
2024-02-12 04:00:40 +01:00
|
|
|
Open `//users/aspen/bbbg/src/bbbg/core.clj` in a buffer, then follow the
|
2022-01-29 18:53:53 +01:00
|
|
|
instructions at the end of the file
|
|
|
|
|
2022-01-29 19:01:43 +01:00
|
|
|
## Deployment
|
2022-01-29 18:53:53 +01:00
|
|
|
|
2022-01-29 19:01:43 +01:00
|
|
|
### With nix+terraform
|
2022-01-29 18:53:53 +01:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2022-01-29 19:00:19 +01:00
|
|
|
To deploy a new version of the application, after following "installing
|
|
|
|
dependencies" above, run the following command in a context with ec2
|
2022-01-29 18:53:53 +01:00
|
|
|
credentials available:
|
|
|
|
|
|
|
|
``` shell-session
|
|
|
|
$ 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`
|
|
|
|
|
2022-01-29 19:01:43 +01:00
|
|
|
### Otherwise
|
2022-01-29 18:53:53 +01:00
|
|
|
|
2022-01-29 19:00:19 +01:00
|
|
|
¯\\\_(ツ)_/¯
|
2022-01-29 18:53:53 +01:00
|
|
|
|
2022-01-29 19:00:19 +01:00
|
|
|
You'll need:
|
2022-01-29 18:53:53 +01:00
|
|
|
|
2022-01-29 19:00:19 +01:00
|
|
|
- An uberjar for bbbg; the canonical way of building that is `nix-build
|
2024-02-12 04:00:40 +01:00
|
|
|
/path/to/depot -A users.aspen.bbbg.server-jar` but I\'m not sure how that
|
2022-01-29 19:00:19 +01:00
|
|
|
works outside of nix
|
2022-01-29 18:53:53 +01:00
|
|
|
- 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
|