From 399eb8a29d076863a48932df2126b3525c648e0e Mon Sep 17 00:00:00 2001 From: Benjamin Sherriff Date: Thu, 5 Sep 2024 12:11:54 -0400 Subject: [PATCH] Updated the readme, docker files, and makefile --- .env | 2 -- Dockerfile | 13 ------------- Makefile | 6 +++--- README.md | 43 ++++++++++++++++++++++++++++++++++--------- docker-compose.yml | 15 ++++----------- 5 files changed, 41 insertions(+), 38 deletions(-) diff --git a/.env b/.env index 3d93168..48bf773 100644 --- a/.env +++ b/.env @@ -17,8 +17,6 @@ MINIO_PORT_INTERNAL=9001 REDIS_HOST=localhost REDIS_PORT=6379 -SERVICE_HOST=localhost -SERVICE_PORT=5000 DATA_DIR_PATH= # OPTIONAL DISCORD_TOKEN= diff --git a/Dockerfile b/Dockerfile index 88e744d..c7be9a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,18 +11,6 @@ COPY Cargo.toml ./ RUN apt-get update && apt-get install -y cmake RUN cargo build --release -# ====== -# Keys -# ====== -FROM debian:bookworm-slim as keys -WORKDIR /keys - -RUN apt-get update && apt-get install -y openssl libpq-dev -RUN openssl genrsa -out private_key.pem 4096 -RUN openssl rsa -in private_key.pem -pubout -outform PEM -out public_key.pem -RUN chmod 600 private_key.pem -RUN chmod 644 public_key.pem - # ========== # Packages # ========== @@ -61,7 +49,6 @@ USER root COPY --from=builder /builder/target/release/service /usr/local/bin/service COPY --from=packages /packages /usr/bin -COPY --from=keys /keys /keys RUN apt-get update && apt-get install -y libc6 libc6-dev libopus-dev libpq5 libpq-dev python3-pip ffmpeg diff --git a/Makefile b/Makefile index 51cd163..38530ed 100644 --- a/Makefile +++ b/Makefile @@ -34,17 +34,17 @@ clean: ## Clean the project @echo "Clean complete" docker-up: ## Start the app - @docker compose --profile backend --profile siren up -d + @docker compose --profile backend --profile bot up -d docker-down: ## Stop the app - @docker compose --profile backend --profile siren down + @docker compose --profile backend --profile bot down docker-build: ## Build the docker image @docker compose build docker-clean: ## Stop the docker containers and remove volumes @echo "Stopping docker container and removing volumes..." - @docker compose --profile backend --profile siren down -v + @docker compose --profile backend --profile bot down -v @echo "Docker container stopped and volumes removed" docker-refresh: docker-clean backend-up ## Refresh the docker containers diff --git a/README.md b/README.md index 906f2e7..fd80c4b 100644 --- a/README.md +++ b/README.md @@ -6,19 +6,27 @@ Siren is a D&D Bot built for Discord, written in Rust. Features include: - Play tracks from Youtube or locally hosted files - Assistant DM tools to be defined later +- ChatGPT integration + +## Requirements +- [Docker](https://www.docker.com/) +- **Optional**: [Docker Compose](https://docs.docker.com/compose/install/) ## Running 1. Setup the Discord Developer Application and bot -2. Copy `.env.TEMPLATE` to `.env` and fill out the fields -3. Build the [Docker](https://www.docker.com/) application with `make build` +2. Create `.env.local` and override any variables from `.env` + - At minimum, `DISCORD_TOKEN` must be set. See [instructions](#setup-discord-developer-application) for additional steps. +3. Build the Docker application with `make build` 4. Start the application with `make up` -### Setting up the Discord Developer Application +

Setting up the Discord Developer Application

Visit the [Discord Developer Portal](https://discord.com/developers/applications) and create a new application. Click [here](https://discord.com/developers/docs/intro) for guides and more information. Required Scopes: - - bot - - application.commands +``` +bot +application.commands +``` Example Invite: ``` @@ -30,6 +38,26 @@ The DISCORD_TOKEN (used in the `.env file`) can be found under the Bot tab on th ![DISCORD_TOKEN Example](docs/discord_token_example.png) +### Commands +Siren utilizes Discord slash commands. To view the commands, run `/help` in a server where the bot is installed. The following commands are available: + +| Command | Description | +| --- | --- | +| `/play` | Play a track from Youtube or locally hosted files | +| `/pause` | Pause the current track | +| `/resume` | Resume the current track | +| `/skip` | Skip the current track | +| `/stop` | Stop the current track | +| `/queue` | ***TODO*** - Display the current queue | +| `/clear` | ***TODO*** - Clear the current queue | +| `/shuffle` | ***TODO*** - Shuffle the current queue | +| `/loop` | ***TODO*** - Loop the current track | +| `/nowplaying` | ***TODO*** - Display the current track | +| `/volume` | Set the volume of the bot | +| `/ping` | Display the bot's latency | +| `/roll` | Roll a dice | +| `/help` | ***TODO*** - Display a list of commands | + ## Contributing [Rust](https://www.rust-lang.org/) must be installed to run locally. See [serenity-rs/serenity](https://github.com/serenity-rs/serenity) for more information about Rust Discord API Library. @@ -68,7 +96,7 @@ The following packages must be installed for [serenity-rs/songbird](https://gith ### Running Locally -1. Start the backend containers with `make refresh` +1. Start the backend containers with `make docker-refresh` 2. Start the application with `make run` The application can also be tested from within a Docker container: @@ -76,6 +104,3 @@ The application can also be tested from within a Docker container: docker build -t siren:latest . docker run --env-file .env -it --rm --name siren siren:latest ``` - -### Authentication -The Siren service uses a stateful JWT authentication system, which allows for the ability to revoke and expire tokens, as well as to allow for the ability to have multiple tokens per user. A public/private key is needed for the JWT. The keys can be generated with `./generate_keys.sh`. These keys should be located within a `/keys` directory in the root of the project. The `KEYS_DIR_PATH` within the service's .env file should be updated to reflect the location of the keys. \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 8726df5..23842f7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ name: siren services: bot: image: siren-service:${SIREN_VERSION:-latest} - container_name: siren-service + container_name: siren-bot build: context: . dockerfile: ./Dockerfile @@ -16,23 +16,16 @@ services: - VERSION=${SIREN_VERSION:-latest} env_file: *env environment: - DATABASE_HOST: db + DATABASE_HOST: postgres DATABASE_PORT: 5432 REDIS_HOST: redis REDIS_PORT: 6379 - MINIO_HOST: minio - MINIO_PORT: 9000 - SERVICE_HOST: service - SERVICE_PORT: 5000 DATA_DIR_PATH: /data volumes: - - ${DATA_DIR_PATH:-/data}:/data - ports: - - ${SERVICE_PORT:-5000}:5000 + - ${DATA_DIR_PATH:-~/data}:/data depends_on: - - db + - postgres - redis - - minio networks: - frontend - backend