Skip to main content

Installation

Start the appliance from the published image with docker run, or build it from the source code with Docker Compose.

Run with Docker

Pick a folder on the Docker host for the data volume, such as /path/to/discord-stonker-bot, then start the container.

bash
sudo docker run -d -v /path/to/discord-stonker-bot:/config -e "PGID=1000" -e "PUID=1000" -e "TZ=America/New_York" --restart always --user 0:0 --net=host --name discord-stonker-bot mrjackyliang/discord-stonker-bot:latest
  • -v …:/config — The host folder that keeps the database and the installation key.
  • PUID and PGID — The user and group that own every file in that folder and run every service, including PostgreSQL. Use IDs from 1 through 60000.
  • TZ — An IANA time zone, such as America/New_York.
  • --user 0:0 — Starts the container's service manager as root, which then runs the bot, the control panel, and the worker as PUID.
  • --net=host — Shares the host's network. The only port the container opens is the control panel's port, 22604, because PostgreSQL listens only on a Unix socket inside the container.

info

Earlier versions mounted the state folder at /data. Change the mount to the same host folder at /config; the first start moves postgres/ into database/, moves the old key into keys/installation.key, and converts its representation without changing its key bytes. An unchanged old run line still starts from /data and performs the same internal migration, while logging that the mount is deprecated.

There's no database password or admin account to set. You create the first account in the browser with a one-time setup code.

To update, remove the container and the old image, then run the same docker run command again. The host folder keeps your data.

bash
sudo docker rm --force discord-stonker-bot && sudo docker rmi mrjackyliang/discord-stonker-bot:latest

Build with Docker Compose

Clone the repository and work from its root folder.

bash
git clone https://github.com/mrjackyliang/discord-stonker-bot.git
cd discord-stonker-bot

Compose Environment File

Copy the root sample to .env next to compose.yml, then add any settings you want to change, such as TZ.

bash
cp .env.sample .env
.env
dotenv
PGID="1000"
PUID="1000"
TZ="UTC"

PGID, PUID, and TZ are the only settings most installs need. Compose also loads apps/bot/.env when it exists, but no setting is required there.

warning

Set PUID, PGID, TZ, and the other Compose settings in the root .env, not in apps/bot/.env. The environment block in compose.yml fills these keys from your shell or the root .env, and Docker Compose gives that block priority over apps/bot/.env.

See Environment Variables for every setting and its default.

Start the Appliance

Build the image and start the container in the background, then check its status.

bash
docker compose up --build --detach
docker compose ps

npm run deploy:container from the repository root runs the same docker compose up --build --detach command.

Docker marks the container healthy only when the bot, PostgreSQL, control panel, and worker are all up and GET /health answers with HTTP 200. The image checks every 30 seconds after a 30-second start period.

Update the Appliance

Get the newer source code, then run the same command to rebuild the image and replace the container.

bash
docker compose up --build --detach

Stop or Remove the Appliance

docker compose down stops and removes the container but keeps the data volume.

bash
docker compose down

danger

First Start

On the first start, the appliance sets up PostgreSQL under /config/database/, applies the database migrations, and creates the installation key at /config/keys/installation.key. The keys/ folder has mode 0700, and the key is 64 lowercase hexadecimal characters plus a newline with mode 0600. The bot, the control panel, and the worker start after these steps finish.

New database migrations run automatically on every start after an update. It is recommended to back up the database first, as described in Storage and Backups.

Open the Control Panel

Open http://<docker-host>:22604/ in a browser, where <docker-host> is the name or address of the machine that runs Docker. The first visit shows Set up your account, which asks for the setup code from the container log, and First-Run Setup walks you through the rest.