Self-Hosting Ticketer
Looking to host the Ticketer bot on your own machine or server? The only required software to do so is Docker Engine. Need help? Join the Ticketer support server! This tutorial assumes you are running Linux to self-host the bot but any other operating system should work fine as well.
Creating the Compose File
Create a directory/folder with any name (like "Ticketer") and then create a file in that directory named "compose.yaml".
$mkdir Ticketer && cd Ticketer
$nano compose.yaml
Copy and paste the following content in the created file:
1name: 'ticketer'
2
3services:
4 database:
5 container_name: ticketer-database
6 image: mariadb:11
7 restart: always
8 healthcheck:
9 test: ['CMD', 'healthcheck.sh', '--connect', '--innodb_initialized']
10 interval: 10s
11 retries: 3
12 start_period: 10s
13 networks:
14 - ticketer-database-network
15 volumes:
16 - ticketer-database-data:/var/lib/mysql
17 environment:
18 MARIADB_DATABASE: ${DB_DATABASE}
19 MARIADB_USER: ${DB_USER}
20 MARIADB_PASSWORD: ${DB_PASSWORD}
21 MYSQL_TCP_PORT: ${DB_PORT}
22 MARIADB_RANDOM_ROOT_PASSWORD: true
23 ports:
24 - ${DB_PORT}:${DB_PORT}
25
26 bot:
27 container_name: ticketer-bot
28 # You can change "latest" to any available version such as "3.4.0".
29 image: ghcr.io/carelessinternet/ticketer-bot:latest
30 # Change the platform to the one on your linux environment (amd64, arm64).
31 platform: linux/arm64
32 restart: unless-stopped
33 depends_on:
34 database:
35 condition: service_healthy
36 networks:
37 - ticketer-database-network
38 env_file:
39 - .env.bot.production.local
40 - .env.database.production.local
41 environment:
42 NODE_ENV: production
43
44networks:
45 ticketer-database-network:
46 driver: bridge
47
48volumes:
49 ticketer-database-data:
50
Environment Variables
You will need the credentials to the Discord bot/application. If you have not already, create a new Discord application (enable the "Server Members" intent!) and edit the following variables with the appropriate credentials in a new file named ".env.bot.production.local". The variable DISCORD_GUILD_ID is the server (ID) where private commands are used. Put the details inside the quotation marks for the variables that have them!
$nano .env.bot.production.local
.env.bot.production.localDISCORD_APPLICATION_ID=""DISCORD_BOT_TOKEN=""DISCORD_GUILD_ID=""DISCORD_OWNER_ID=""
The database also requires a few credentials to run. Create a file named ".env.database.production.local" and then create some login credentials with the following template below. You can change every variable to have whatever value you want except for DB_HOST.
$nano .env.database.production.local
.env.database.production.localDB_HOST="ticketer-database"DB_DATABASE="Ticketer"DB_PORT=3306DB_USER=""DB_PASSWORD=""
Running the Bot
Now it is time to run the bot! Run the following command to start the database and bot (this may take some time):
$docker compose --env-file ./.env.database.production.local --file compose.yaml up -d
To deploy the application commands of the bot, run the following line:
$docker exec ticketer-bot sh -c "cd /src/apps/bot && pnpm commands:deploy:production"
Once the commands have been deployed, run the /migrate command in Discord to deploy any database changes that may be needed:
/migrate
If you want to stop the database and bot, run the commands below:
$docker container stop ticketer-bot
$docker container stop ticketer-database
Accessing The Database
If you want to access the database, you can do so by running the two commands below and replacing "USERNAME" with the username you chose in the environment variable:
$docker exec -it ticketer-database bash
$mariadb -u USERNAME -p