This is a guide to self host the Tickets bot. Which was announced to sunset on the 5th of March 2025 in their support server. This guide will help you set up the bot on your own machine using Docker. This is not an official guide and I will not provide support.
- You must have knowledge of how to use, deploy and run containers (specifically Docker)
- You must have an idea of how to use a terminal
- You should have a basic understanding of GoLang, Rust, and Svelte
- You should have a basic understanding of how to use a database (specifically PostgreSQL)
To be completely honest, I still don't know. The image below is a rough diagram of how I think the bot works after nearly a week of tinkering with the TicketsBot codebase. The dotted boxes are the containers that I did not implement into the docker-compose.yaml
in this repository.
The image above was made using Excalidraw.
-
Open a terminal in the folder you want to install the bot in. (Or create a folder and open a terminal in that folder)
-
Clone this repository into that folder (
git clone https://github.com/DanPlayz0/ticketsbot-self-host-guide.git .
)- The
.
at the end is important as it clones the repository into the current folder
- The
-
Create an
.env
file by copying the provided.env.example
file.DISCORD_BOT_TOKEN
: your bot token (e.g.OTAyMzYyNTAxMDg4NDM2MjI0.YXdUkQ.TqZm7gNV2juZHXIvLdSvaAHKQCzLxgu9
)DISCORD_BOT_CLIENT_ID
: your bot's client ID (e.g.508391840525975553
)DISCORD_BOT_OAUTH_SECRET
: your bot's client secret (e.g.AAlRmln88YpOr8H8j1VvFuidKLJxg9rM
)DISCORD_BOT_PUBLIC_KEY
: your bot's public key (e.g.fcd10216ebbc818d7ef1408a5c3c5702225b929b53b0a265b82e82b96a9a8358
)ADMIN_USER_IDS
: a comma-separated list of user IDs (e.g.209796601357533184,585576154958921739,user_id,user_id
, a single id would be209796601357533184
)DISCORD_SUPPORT_SERVER_INVITE
: the invite link to your support server (e.g.https://discord.gg/ticketsbot
)DASHBOARD_URL
: the URL of your dashboard (e.g.http://localhost:5000
)LANDING_PAGE_URL
: the URL of your landing page (e.g.https://ticketsbot.cloud
)API_URL
: the URL of your API (e.g.http://localhost:8082
)DATABASE_HOST
: your PostgreSQL host (e.g.postgres:5432
)DATABASE_PASSWORD
: your PostgreSQL password (e.g.password
)CACHE_DATABASE_HOST
: your cache database host (e.g.postgres-cache:5432
)CACHE_DATABASE_PASSWORD
: your cache database password (e.g.password
)S3_ENDPOINT
: the endpoint of your S3 bucket (e.g.minio:9000
)S3_ACCESS
: the access key of your S3 bucket (e.g.AbCdEfFgHiJkLmNoPqRsTuVwXyZ
)S3_SECRET
: the secret key of your S3 bucket (e.g.AbCdEfFgHiJkLmNoPqRsTuVwXyZ
)ARCHIVER_AES_KEY
: your AES-128 key (e.g.randomstring
)- Bash:
openssl rand -hex 16
- NodeJS:
node -e "console.log(require('crypto').randomBytes(16).toString('hex'))"
- Bash:
ARCHIVER_ADMIN_AUTH_TOKEN
: your archiver admin auth token (e.g.randomstring
)SENTRY_DSN
: your Sentry DSN (e.g.https://[email protected]/0
)
-
Replace the placeholders in the following command and paste it at the bottom of
init-archive.sql
. There are 2 placeholders in the command,${BUCKET_NAME}
and${S3_ENDPOINT}
. Replace them with your bucket name and S3 endpoint respectively. You can also just edit theinit-archive.sql
file too, you just have to uncomment it (by removing the--
at the start of the line) and replace variables there.INSERT INTO buckets (id, endpoint_url, name, active) VALUES ('b77cc1a0-91ec-4d64-bb6d-21717737ea3c', 'https://${S3_ENDPOINT}', '${BUCKET_NAME}', TRUE);
-
Run
docker compose up -d
to pull the images and start the bot. -
Configure the Discord bot. (see below)
-
Register the slash commands (see below)
As this bot is self-hosted, you will need to configure the bot yourself. Here are the steps to configure the bot:
- Go to the Discord Developer Portal
- Click on the application you created for the bot
- Set the
Interactions Endpoint URL
to${HTTP_GATEWAY}/handle/${DISCORD_BOT_CLIENT_ID}
- Replace
${HTTP_GATEWAY}
with the URL of your HTTP Gateway (e.g.http://localhost:8080
, you must have a publicly accessible URL not localhost) - Replace
${DISCORD_BOT_CLIENT_ID}
with your bot's application/client ID (e.g.508391840525975553
)
- Replace
- Go to the OAuth2 tab
- Add the redirect URL
${DASHBOARD_URL}/callback
to the OAuth2 redirect URIs- Replace
${DASHBOARD_URL}
with the URL of your API (e.g.http://localhost:8080
, make sure this matches what you set in the Setup section)
- Replace
-
Create the
commands.Dockerfile
and copy the following code block (this registers the commands with the bot)# Build container FROM golang:1.22 AS builder RUN go version RUN apt-get update && apt-get upgrade -y && apt-get install -y ca-certificates git zlib1g-dev WORKDIR /go/src/github.com/TicketsBot RUN git clone https://github.com/TicketsBot/worker.git WORKDIR /go/src/github.com/TicketsBot/worker RUN git submodule update --init --recursive --remote RUN set -Eeux && \ go mod download && \ go mod verify RUN GOOS=linux GOARCH=amd64 \ go build \ -tags=jsoniter \ -trimpath \ -o main cmd/registercommands/main.go # Executable container FROM ubuntu:latest RUN apt-get update && apt-get upgrade -y && apt-get install -y ca-certificates curl COPY --from=builder /go/src/github.com/TicketsBot/worker/locale /srv/worker/locale COPY --from=builder /go/src/github.com/TicketsBot/worker/main /srv/worker/main RUN chmod +x /srv/worker/main RUN useradd -m container USER container WORKDIR /srv/worker ENTRYPOINT ["/srv/worker/main"]
-
Build the register commands cli utility using
docker build -t ticketsbot/registercommands -f commands.Dockerfile .
-
Get help by running
docker run --rm ticketsbot/registercommands --help
-
Register the commands
- Global commands only:
docker run --rm ticketsbot/registercommands --token=your_bot_token --id=your_client_id
- Global & Admin commands by running
docker run --rm ticketsbot/registercommands --token=your_bot_token --id=your_client_id --admin-guild=your_admin_guild_id
- Global commands only:
-
Clone the worker repository (
git clone https://github.com/TicketsBot/worker.git
) -
Change directory to the
worker
folder (cd worker
) -
Run
go run cmd/registercommands/main.go --token=your_bot_token --id=your_client_id
- If you want to register the admin commands, add
--admin-guild=your_admin_guild_id
to the command
- If you want to register the admin commands, add
-
If you get errors related to zlib (
undefined: Zstream
,undefined: NewZstream
,undefined: zNoFlush
,undefined: zSyncFlush
, etc)- You are missing the zlib package and GDL uses it.
- You can install it by running one of the following (depending on your package manager)
- Ubuntu:
apt-get install zlib1g-dev
- CentOS:
yum install zlib-devel
- Ubuntu:
-
What can I host this on?
- You should be able to host this on any machine that can run Docker containers
-
What are the system requirements?
- I cannot recommend any specific requirements, but I can give you some information on the resources used by the bot (CPU metrics are out of 1200% as i was using a 6 core CPU with 12 logical processors):
- Starting up the bot the peak was around 475.44MB of RAM and 43.21% CPU. (This was on a fresh start, it may vary)
- After using the bot for a while, the bot was using around 1.5GB of RAM and 18% of a CPU.
- I cannot recommend any specific requirements, but I can give you some information on the resources used by the bot (CPU metrics are out of 1200% as i was using a 6 core CPU with 12 logical processors):
-
Can I turn off the logging?
-
Kinda of, in certain containers there are environment variables, like the ones below which you can remove:
RUST_BACKTRACE: 1 RUST_LOG: trace
-
-
How do I update the bot?
- The docker compose uses a specific hash for the bot's containers, so you will have to manually find the new hash and update the
docker-compose.yaml
file.
- The docker compose uses a specific hash for the bot's containers, so you will have to manually find the new hash and update the
-
How do I get rid of the
ticketsbot.net
branding?- If you have knowledge of how to compile GoLang, Rust, and Svelte, you can change the branding in the bot's source code and recompile the bot and update those container hashes in
docker-compose.yaml
file and then re-run the bot.
- If you have knowledge of how to compile GoLang, Rust, and Svelte, you can change the branding in the bot's source code and recompile the bot and update those container hashes in
-
I want anyone to be able to use the dashboard, how do I do that?
- You gotta setup a reverse proxy (examples being; NginX, Caddy, Traefik) with the following routes (assuming you are using the default ports from the compose file):
api.example.com
->http://localhost:8082
(api container)dashboard.example.com
->http://localhost:5000
(dashboard container)gateway.example.com
->http://localhost:8080
(http-gateway container)
- You gotta setup a reverse proxy (examples being; NginX, Caddy, Traefik) with the following routes (assuming you are using the default ports from the compose file):