* Rename HOSTNAME env var to BASE_URL (and document it)
* BASE_URL.rstrip("/")
Prevent errors if you include / in your env var
* Trailing newline
6 KiB
Deploying Nephthys on Hack Club Coolify
Here's a mostly-complete guide to deploying a new instance of Nephthys on the Hack Club Coolify.
You can also follow it to deploy Nephthys elsewhere, but you'll have to replace the Coolify-specific steps with writing docker compose files, or whatever else floats your boat.
Deploying the database to Coolify
- Navigate to the amber/nephthys project on the Hack Club HQ Coolify
- Navigate to the Production environment and add a new resource
- To add the database, select PostgreSQL
- Select the coolify-app-server-b server (as it's currently recommended)
- Select standard PostgreSQL
- Update the database name to something useful like "Flavorbase" or "Construct Data". Perhaps add a description too.
- You'll need the Postgres URL (internal) later, so write it down or idk, keep the tab open or something
- You can start the database now, or later. Just don't forget to do it
Deploying Nephthys to Coolify
-
In the same Production environment, add a new application
-
Select Private Repository (with GitHub App) (this ensures auto-deploys work)
-
Select the coolify-app-server-b server (to match the database)
-
Use the coolify-hackclub GitHub app (because everyone else uses it, I guess)
-
Select the nephthys repository
-
Select Dockerfile as the Build Pack
-
Update the name and description to be descriptive
-
Update the domain to be a custom one you've set up on hackclub/dns (it should be
[something].nephthys.hackclub.com) (or leave the ugly default domain) -
Environment variables! We'll set them later
Creating the Slack app
Note: These steps have to be done by a Workspace Admin (otherwise it will be unable to fully delete threads in the tickets channel).
- Go to https://api.slack.com/apps
- Create New App > From a manifest
- Select YAML. Paste the manifest.yml file (but don't submit it yet)
- Update the
https://nephthys.hackclub.com/URLs in the manifest to match the bot's domain (see above), and update thename,description, and bot user'sdisplay_name. - Important: Change the name of the
/dm-magic-linkcommand! Or remove it entirely if it's not relevant - Review the app's permissions and authorise it
- Click OAuth & Permissions in the sidebar, and hit Install to Hack Club
Setting environment variables
-
Go back to the Nephthys resource you created in Coolify, and click on Configuration > Environment Variables. Click Developer view (production environment variables) to make it easier to add all the variables.
-
Add the required environment variables (see .env.sample for an up-to-date list of environment variables):
# Keep these as they are ENVIRONMENT="production" PORT=3000 # Copy these from the Slack bot OAuth & Permissions screen SLACK_USER_TOKEN="xoxp-..." SLACK_BOT_TOKEN="xoxb-..." # Slack bot basic information screen SLACK_SIGNING_SECRET="..." # This should probably be your Slack ID SLACK_MAINTAINER_ID="U..." # Channels that will be used by the bot SLACK_HEARTBEAT_CHANNEL="C..." SLACK_TICKET_CHANNEL="C..." SLACK_BTS_CHANNEL="C..." SLACK_HELP_CHANNEL="C..." # Slack user group for the support team SLACK_USER_GROUP="S..." # Copy this from the PostgreSQL resource you created earlier DATABASE_URL="postgres://postgres:blahblah@somewhere:5432/postgres" # Pick a transcript from the transcripts/ folder (your event will probably have its own) PROGRAM="flavortown" # Choose a title to be shown to helpers at the top of the App Home APP_TITLE="Heidi the Assistant" # Hack Club AI API key for generating ticket titles (highly recommended) HACK_CLUB_AI_API_KEY="sk-hc-v1-..." # Set this to anything SITE_API_KEY="none" # Set this to the URL where the site will be hosted BASE_URL="https://summer.nephthys.hackclub.com"SITE_API_KEY(andSITE_URL) are only used for generating magic links for Summer of Making, so they don't have to be included (butSITE_API_KEYmust be set due to a bug)
-
There's more optional environment variables that you can set, which I shall document here:
# Export logs to an OpenTelemetry endpoint (optional) # example using Loki: OTEL_EXPORTER_OTLP_LOGS_ENDPOINT="https://loki.example.com/otlp/v1/logs" # If HTTP Basic Authentication is required for the OTLP endpoint, specify it here # If your password has special characters, switch to normal view to add it, and check the "Is Literal?" checkbox OTEL_EXPORTER_OTLP_LOGS_BASIC_AUTH="username:password" # You can change the OTel service name if you want, but you don't have to OTEL_SERVICE_NAME="nephthys" # Setting this to any value disables daily summary messages (yes, this is counter-intuitive and will be changed soon) DAILY_SUMMARY="" # Set the log level (defaults to "WARNING" in production) LOG_LEVEL="WARNING" # Override the log level for console output LOG_LEVEL_STDERR="WARNING" # Override the log level for OpenTelemetry output LOG_LEVEL_OTEL="WARNING" -
Don't forget to click Save All Environment Variables
Some final pre-requisites
- Add the bot to the BTS channel, help channel, tickets channel, and heartbeat channel
- Add the user who authorised the bot (probably you!) to (at least) the tickets channel
- Ensure your DNS PR has been made and merged (if applicable)
- You can also set a profile picture for the Slack bot in the Slack app settings at this point
- The database should be started by this point
Deploying
- Press Deploy on the new Nephthys resource in Coolify
- It will take some time to build, deploy, and start
- You should see a message in the heartbeats channel and the bot should respond to messages in the help channel
- If it isn't responding to anything, check the logs in Coolify for errors, and double-check all the URLs in the Slack app settings are valid
