Skip to content

Repository files navigation

self-destruct

run your own self destructing note service

Prerequisites

  • Java 17 or newer (21 recommended; required by Ring / Jetty 12)
  • Clojure CLI (clj / clojure)
  • PostgreSQL available over TCP with a role/password your JDBC URL can use

Development Mode

Set Environment Variables & Secrets

Copy the local example, then edit values to match your machine:

cp dev.env.example .env

.env is gitignored. On startup the app loads it automatically for any variables not already set in the process environment (so exported env vars and CI/production still win). The example includes:

  • DATABASE_URL — JDBC URL with user/password (not Unix peer auth)
  • DATABASE_ENCRYPTION_KEY — key used to encrypt messages at rest
  • SESSION_COOKIE_KEY — must be exactly 16 characters/bytes
  • ENABLE_WORKERS — set false locally unless you want the expiry worker running

Setup Local Development Database

Create a Postgres role and database that match dev.env.example (user/password selfdestruct / selfdestruct):

createuser selfdestruct
psql -c "ALTER USER selfdestruct WITH PASSWORD 'selfdestruct';"
createdb -O selfdestruct self-destruct-dev
clj -M:migrate

If you use a different role, update DATABASE_URL in .env. JDBC connections use TCP auth; peer auth via Unix sockets is not used.

Run the app

After migrations have been applied:

clj -M:dev-main

That starts Garden CSS auto-compile and the Ring server (default port 8000).

Equivalent pieces if you prefer to run them separately:

clj -M:css watch
clj -M:run -- --port 8000

:run uses the production entrypoint (-main). :dev-main uses -dev-main with Ring reload.

Running Tests

./run-tests-local.sh

This recreates self-destruct-test, runs migrations, then clj -M:test. Ensure your Postgres role can create that database (or create it yourself and point DATABASE_URL at it).

Continuous Integration

Pull requests and pushes to master run on GitHub Actions (.github/workflows/ci.yml): Postgres service, clj -M:migrate, clj -M:test, and an uberjar build.

Database Migrations

  • Migratus handles schema changes; files live in resources/migrations.
  • Create a new pair of *.up.sql / *.down.sql files under resources/migrations (timestamp prefix, e.g. 20260731120000-add-thing.up.sql).
  • Apply migrations with clj -M:migrate or java -jar target/self-destruct.jar --migrate in production.

Production Build

clj -T:build uber

Writes target/self-destruct.jar (compiles Garden CSS first, then AOT + uberjar).

For FreeBSD production deploy (app user, rc.d, nginx, certbot, backups), see DEPLOYMENT_FREEBSD.md and the scripts under scripts/.

Required environment variables (also listed in .env.example):

  • DATABASE_URL
  • DATABASE_ENCRYPTION_KEY
  • PORT
  • SESSION_COOKIE_KEY (exactly 16 characters/bytes)

Optional:

  • HOST (e.g. 127.0.0.1 so Jetty only accepts local/nginx traffic)
  • REPORTED_LOG_LEVEL (defaults to warn; min level for Sentry when enabled)
  • LOG_APPENDER (println or sentry)
  • SENTRY_DSN (required only when LOG_APPENDER=sentry)
  • ENABLE_WORKERS (defaults to enabled; set false to disable background workers)
  • MESSAGE_EXPIRE_MINUTES (defaults to 1440 / 24 hours)
  • WORKER_DELAY_SECONDS (defaults to 3600 / 1 hour)
  • SECURE_DEFAULTS (set true to use Ring secure-site-defaults)

License

Copyright © Chad Stovern.

About

run your own self destructing note service

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages