-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Containerize the application + Other features #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
85ddbdd
18c7aed
c6f7bd9
aecb298
52bc439
c72133b
3e56254
82e7436
16ffa21
f3bf18c
f0ef376
2887806
e0b8486
80aca25
b360f08
a4259b3
0bd145c
42ce1d9
cda055d
c0c2577
876f9b8
e5c238a
d11c6b1
4425b1c
c284a05
0e93a44
7da26a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Copy this file to .env and fill in your values | ||
|
|
||
| # Discord Configuration | ||
| DISCORD_CLIENT_ID="your_discord_client_id" | ||
| DISCORD_GUILD_ID="your_discord_guild_id" | ||
| DISCORD_TOKEN="your_discord_bot_token" | ||
|
|
||
| # PocketBase Configuration | ||
| POCKETBASE_EMAIL="admin@example.com" | ||
| POCKETBASE_PASSWORD="your_secure_password" | ||
|
|
||
| # MySQL Configuration | ||
| MYSQL_USER=test | ||
| MYSQL_PASSWORD=pass | ||
| MYSQL_ROOT_PASSWORD=test_pass | ||
|
|
||
| # Note: Database connection details are automatically configured via Docker containers | ||
| # The following variables are set automatically in docker-compose.yml: | ||
| # - POCKETBASE_HOST=http://moderation-db:8080 | ||
| # - MYSQL_HOST=message-db | ||
| # - MYSQL_PORT=3306 | ||
| # | ||
| # Access the pocketbase admin panel at: http://localhost:8080/_/ (or your server ip) to setup your admin account |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,7 @@ | ||
| .env | ||
| pocketbase/* | ||
| .env | ||
|
|
||
| # Database data directories | ||
| pocketbase-db/data/ | ||
| message-db/data/ | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| FROM alpine:latest | ||
|
|
||
| ARG PB_VERSION=0.20.3 | ||
|
|
||
| RUN apk add --no-cache \ | ||
| unzip \ | ||
| ca-certificates | ||
|
|
||
| # download and unzip PocketBase | ||
| ADD https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_amd64.zip /tmp/pb.zip | ||
| RUN unzip /tmp/pb.zip -d /pb/ | ||
|
|
||
| # create data directory for databases | ||
| RUN mkdir -p /pb/pb_data | ||
|
|
||
| # copy startup script | ||
| COPY start.sh /pb/start.sh | ||
| RUN chmod +x /pb/start.sh | ||
|
|
||
| # uncomment to copy the local pb_migrations dir into the image | ||
| # COPY ./pb_migrations /pb/pb_migrations | ||
|
|
||
| # uncomment to copy the local pb_hooks dir into the image | ||
| # COPY ./pb_hooks /pb/pb_hooks | ||
|
|
||
| EXPOSE 8080 | ||
|
|
||
| # create volume for persistent data storage | ||
| VOLUME ["/pb/pb_data"] | ||
|
|
||
| # start PocketBase with auto-admin setup | ||
| CMD ["/pb/start.sh"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,84 @@ Honkbot2 is the new discord bot for the UManitoba Computer Science Lounge writte | |
|
|
||
| Honkbot2 contains a wide variety of moderation and verification functionalities. | ||
| To learn more read the [Moderation Handbook](https://umanitobacssa.ca/docs/discordModHandbook.pdf) | ||
|
|
||
| ## Quick Start | ||
|
|
||
| 1. **Clone the repository** | ||
| ```bash | ||
| git clone <repository-url> | ||
|
Comment on lines
+8
to
+12
|
||
| cd honkbot2 | ||
| ``` | ||
|
|
||
| 2. **Set up environment variables** | ||
| ```bash | ||
| cp .env.example .env | ||
| # Edit .env with your Discord bot credentials | ||
| ``` | ||
|
|
||
| 3. **Start the containers** | ||
| ```bash | ||
| docker compose up -d | ||
| ``` | ||
| *See [Development Commands](#development-commands) for more options for log viewing and rebuilding containers* | ||
|
|
||
| 4. **Set up the pocketbase admin account** | ||
|
|
||
| Go to http://localhost:8080/_/ (or the ip of your remote server) and set up the account with the same credentials as your .env | ||
|
|
||
| The bot will automatically build and start all docker containers, all database networking connections are configured through the created docker network, and it will also auto create the required databases for the first message sent in a discord server. | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| The following variables need to be set in your `.env` file: | ||
|
|
||
| - `DISCORD_CLIENT_ID` - Your Discord application client ID | ||
| - `DISCORD_GUILD_ID` - Your Discord server ID | ||
| - `DISCORD_TOKEN` - Your Discord bot token | ||
| - `POCKETBASE_EMAIL` - Email for PocketBase admin | ||
| - `POCKETBASE_PASSWORD` - Password for PocketBase admin | ||
|
|
||
| ## Database Configuration | ||
|
|
||
| The bot uses two databases that are automatically configured: | ||
|
|
||
| ### MySQL (Message Database) | ||
| - **Host**: `message-db` (container name) | ||
| - **Port**: `3306` | ||
| - **User**: `test` | ||
| - **Password**: `pass` | ||
|
|
||
| ### PocketBase (Moderation Database) | ||
| - **Host**: `moderation-db:8080` (container name) | ||
| - **Admin Panel**: http://localhost:8080/_/ | ||
|
|
||
| ## Development Commands | ||
|
|
||
| ```bash | ||
| # Start all services | ||
| docker-compose up -d | ||
|
|
||
| # View bot logs | ||
| docker-compose logs honkbot | ||
|
|
||
| # View PocketBase logs | ||
| docker-compose logs pocketbase-db | ||
|
|
||
| # View MySQL logs | ||
| docker-compose logs mysql | ||
|
|
||
| # Stop all services | ||
| docker-compose down | ||
|
|
||
| # Rebuild and restart | ||
| docker-compose up --build -d | ||
| ``` | ||
|
|
||
| ## Database Schema | ||
|
|
||
| The MySQL database automatically creates the following tables per Discord server: | ||
|
|
||
| - `messages` - Stores all user messages | ||
| - `message_deleted` - Stores deleted messages for moderation | ||
| - `message_edited` - Stores message edit history | ||
| - `counters` - Stores user statistics (reactions, message counts, etc.) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Use the official Bun image | ||
| # see all versions at https://hub.docker.com/r/oven/bun/tags | ||
| FROM oven/bun:1 | ||
| WORKDIR /usr/src/app | ||
|
|
||
| # Copy package files and install dependencies | ||
| COPY package.json bun.lockb ./ | ||
| RUN bun install --frozen-lockfile | ||
|
|
||
| # Copy all project files | ||
| COPY . . | ||
|
|
||
| # Set environment to production | ||
| ENV NODE_ENV=production | ||
|
|
||
| # Run the app | ||
| USER bun | ||
| ENTRYPOINT [ "bun", "run", "index.ts" ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This root-level
Dockerfileappears to be a duplicate ofpocketbase-db/Dockerfile, butdocker-compose.ymlbuilds PocketBase from./pocketbase-db/. Keeping an unused duplicate Dockerfile is confusing and increases maintenance overhead. Consider deleting it or clearly documenting what it’s for.