Skip to content

Docker

This guide is written for Linux systems. The process is similar on Windows, but the commands may differ.

Before you start, you need to make sure your system meets the requirements.

Unless you know what you're doing and already have a database and reverse proxy set up, using the provided docker-compose.yml file is recommended over pure Docker.

Docker Compose

The default configuration contains two services:

  • Discord Tickets
  • MySQL

Start by making a directory(1) and downloading the docker-compose.yml file from GitHub.

  1. The name isn't important, but tickets-bot is used as an example in this guide.
mkdir tickets-bot && cd tickets-bot
wget https://dl.discordtickets.app/bot/docker-compose.yml
curl -O https://dl.discordtickets.app/bot/docker-compose.yml

You can also download the file in your browser.

Environment variables

Open docker-compose.yml in your preferred text editor(1) and modify the highlighted lines.

  1. nano docker-compose.yml
    

Bug

The value of HTTP_EXTERNAL must be resolvable both from within the container and the host, which means when HTTP_EXTERNAL is an internal address (e.g. http://127.0.0.1), the container and host ports must be the same. This is because the SvelteKit application uses server-side rendering, so the bot makes HTTP requests to itself. Alternatively, you can set the HTTP_INTERNAL value with a different port.

If you are using a reverse proxy and a domain name, this shouldn't be a problem.


Tip

You can middle-click on links to open them in a new tab so you can easily come back to the documentation!

Refer to the configuration documentation for more information about the available environment variables, and return to this page when you have finished.

Environment variables


docker-compose.yml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
version: "3.9"

services:
  mysql:
    image: mysql:8
    restart: unless-stopped
    hostname: mysql
    networks:
      - discord-tickets
    volumes:
      - tickets-mysql:/var/lib/mysql
    environment:
      MYSQL_DATABASE: tickets
      MYSQL_PASSWORD: insecure # (1)!
      MYSQL_ROOT_PASSWORD: insecure # (2)!
      MYSQL_USER: tickets

  bot:
    image: eartharoid/discord-tickets:4.0 # (3)!
    depends_on:
      - mysql
    restart: unless-stopped
    hostname: bot
    networks:
      - discord-tickets
    ports:
      - 8169:8169
    volumes:
      - tickets-bot:/home/container/user
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    tty: true
    stdin_open: true
    # Please refer to the documentation:
    # https://discordtickets.app/self-hosting/configuration/#environment-variables
    environment:
      DB_CONNECTION_URL: mysql://tickets:insecure@mysql/tickets # (4)!
      DISCORD_SECRET: # (5)!
      DISCORD_TOKEN: # (6)!
      ENCRYPTION_KEY: # (7)!
      DB_PROVIDER: mysql
      HTTP_EXTERNAL: http://127.0.0.1:8169 # (8)!
      HTTP_HOST: 0.0.0.0
      HTTP_PORT: 8169
      HTTP_TRUST_PROXY: "false" # (9)!
      PUBLIC_BOT: "false"
      PUBLISH_COMMANDS: "false"
      OVERRIDE_ARCHIVE: null
      SUPER: 319467558166069248 # (10)!
      # TZ: Etc/UTC
      # (11)!
networks:
  discord-tickets:

volumes:
  tickets-mysql:
  tickets-bot:
  1. Change the password for the database user to something secure. This isn't vital if you are not exposing the database to the network, but note that it can't be changed after the container is created.
  2. Change the password for the root database user to something secure. This isn't vital if you are not exposing the database to the network, but note that it can't be changed after the container is created.
  3. Make sure the image tag is the latest version. Discord Tickets follows semantic versioning, but not strictly, so pinning to a minor version is recommended. You can see all available tags on Docker Hub.
  4. Change insecure to the value of MYSQL_PASSWORD.
  5. Refer to Creating the Discord application.
  6. Refer to Creating the Discord application.
  7. Copy the value from the encryption key generator below.
  8. Change this to your server's external IP address, or a domain name that points to it.
  9. If you are using a reverse proxy, set this to true.
  10. You can add more users by separating them with commas (e.g. 319467558166069248,123456789012345678)
  11. If the container's timezone doesn't match the host (e.g. because it is a Windows host), you can uncomment and change the TZ variable.

Creating the Discord application

Warning

Don't skip this section if you already know how to create a Discord application; Discord Tickets requires additional configuration. Using an existing application is not recommended.

  1. Go to the Discord Developer Portal

  2. Create an application

    1. Click the New Application button
    2. Give your application a name, accept the terms of service and click Create

    Screenshot 3. Add a logo, description, and links to your terms of service and privacy policy, then click Save Changes.

    Screenshot 4. Go to the OAuth2 page and click Reset Secret, then Yes, do it!. Copy the new secret and set it as your DISCORD_SECRET environment variable.

    Screenshot 5. Click Add Redirect and enter the value of your HTTP_EXTERNAL environment variable, followed by /auth/callback. Then click Save Changes.

    Examples

    • http://12.345.67.89:8080/auth/callback
    • https://tickets.example.com/auth/callback

    If you set this to https://tickets.example.com/auth/callback, your HTTP_EXTERNAL environment variable must be set to https://tickets.example.com (without a trailing /).

    Screenshot 6. Create the bot user

    1. Go to the Bot page and click Add Bot, then Yes, do it!
    2. Click View Token, then copy the token and set it as your DISCORD_TOKEN environment variable.

    Screenshot 7. Configure the bot

    1. Optionally, disable the "public bot" option to prevent other people from adding your bot to their servers.
    2. Enable the presence, server members and message content intents.

    Screenshot

Don't add the bot to your Discord server yet; you'll do that later.

Encryption key

Copy the value below and set it as the ENCRYPTION_KEY environment variable.

Click to regenerate
Generating...

Starting the bot

Start the containers:

docker-compose up -d

Publishing the commands

First, find the bot container's ID:

docker container ls
1
2
3
CONTAINER ID   IMAGE                            COMMAND                  CREATED          STATUS          PORTS                            NAMES
318bb11719d9   eartharoid/discord-tickets:4.0   "/home/container/scripts/st…"   41 seconds ago   Up 37 seconds   80/tcp, 0.0.0.0:8080->8080/tcp   bot-bot-1
18a3ae0eb999   mysql:8                          "docker-entrypoint.s…"   41 seconds ago   Up 38 seconds   3306/tcp, 33060/tcp              bot-mysql-1

Then, attach to the container:

docker attach 318bb11719d9

You can now interact with the bot's console and publish the commands to Discord:

commands publish

To disconnect from the container, press Ctrl+P Ctrl+Q. If that doesn't work (e.g. if you using the terminal in VS Code), press Ctrl+C instead (which will also restart the bot).

Reverse proxy

If you have a domain name, you should set up a reverse proxy with SSL/TLS and set the HTTP_TRUST_PROXY environment variable to true.

Next steps

If your bot is running, congratulations, you have successfully installed Discord Tickets, and now it's time to set it up in your Discord server.

Join the community on Discord and get notified when updates (with new features and fixes) are released.

Refer to the configuration guide for a step-by-step guide on how to add and configure the bot in your server.

Configuration

Having trouble?

If you haven't got the bot running yet and need help, you can ask for help on Discord or on GitHub.

Pure Docker

This is a very short overview; refer to the Docker Compose guide for more information.

Some required environment variables that you are unlikely to change have defaults set in the Dockerfile:

Name Value
HTTP_HOST 0.0.0.0
HTTP_PORT 80

You need to set the other required environment variables.


Tip

You can middle-click on links to open them in a new tab so you can easily come back to the documentation!

Refer to the configuration documentation for more information about the available environment variables, and return to this page when you have finished.

Environment variables


Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
docker run -itd \
  --name tickets \
  -p 8169:80 \
  -e DB_CONNECTION_URL="mysql://bots:VerySecurePassword123@localhost/tickets0" \
  -e DB_PROVIDER="mysql" \
  -e DISCORD_SECRET="rUpDU2T8K4ZXie8kdpzYsMTLbUhvmBRd" \
  -e DISCORD_TOKEN="ODcwOTg1TY0NjI0NODI2Mzc0.DNg0e0.UYVof7V1v0kRA0HHtGwXKA3UERxwANAZhQiA" \
  -e ENCRYPTION_KEY="445940dbed49eff55df56dd646fa1cb4b686df4cb9ac004a" \
  -e HTTP_EXTERNAL="https://tickets.example.com" \
  -e HTTP_TRUST-PROXY="true" \
  eartharoid/discord-tickets:4.0

The first time you start the container, don't use the -d flag so you can type commands publish in the console to publish the commands to Discord. You can then restart the container in detached mode. Alternatively, set the PUBLISH_COMMANDS environment variable to true to publish commands automatically at startup.

Comments