Updated the readme, docker files, and makefile

This commit is contained in:
2024-09-05 12:11:54 -04:00
parent d08800f9e0
commit 399eb8a29d
5 changed files with 41 additions and 38 deletions

2
.env
View File

@@ -17,8 +17,6 @@ MINIO_PORT_INTERNAL=9001
REDIS_HOST=localhost REDIS_HOST=localhost
REDIS_PORT=6379 REDIS_PORT=6379
SERVICE_HOST=localhost
SERVICE_PORT=5000
DATA_DIR_PATH= # OPTIONAL DATA_DIR_PATH= # OPTIONAL
DISCORD_TOKEN= DISCORD_TOKEN=

View File

@@ -11,18 +11,6 @@ COPY Cargo.toml ./
RUN apt-get update && apt-get install -y cmake RUN apt-get update && apt-get install -y cmake
RUN cargo build --release 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 # Packages
# ========== # ==========
@@ -61,7 +49,6 @@ USER root
COPY --from=builder /builder/target/release/service /usr/local/bin/service COPY --from=builder /builder/target/release/service /usr/local/bin/service
COPY --from=packages /packages /usr/bin 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 RUN apt-get update && apt-get install -y libc6 libc6-dev libopus-dev libpq5 libpq-dev python3-pip ffmpeg

View File

@@ -34,17 +34,17 @@ clean: ## Clean the project
@echo "Clean complete" @echo "Clean complete"
docker-up: ## Start the app 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-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-build: ## Build the docker image
@docker compose build @docker compose build
docker-clean: ## Stop the docker containers and remove volumes docker-clean: ## Stop the docker containers and remove volumes
@echo "Stopping docker container and removing 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" @echo "Docker container stopped and volumes removed"
docker-refresh: docker-clean backend-up ## Refresh the docker containers docker-refresh: docker-clean backend-up ## Refresh the docker containers

View File

@@ -6,19 +6,27 @@
Siren is a D&D Bot built for Discord, written in Rust. Features include: Siren is a D&D Bot built for Discord, written in Rust. Features include:
- Play tracks from Youtube or locally hosted files - Play tracks from Youtube or locally hosted files
- Assistant DM tools to be defined later - 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 ## Running
1. Setup the Discord Developer Application and bot 1. Setup the Discord Developer Application and bot
2. Copy `.env.TEMPLATE` to `.env` and fill out the fields 2. Create `.env.local` and override any variables from `.env`
3. Build the [Docker](https://www.docker.com/) application with `make build` - 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` 4. Start the application with `make up`
### Setting up the Discord Developer Application <h3 id='setup-discord-developer-application'>Setting up the Discord Developer Application</h3>
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. 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: Required Scopes:
- bot ```
- application.commands bot
application.commands
```
Example Invite: 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) ![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 ## 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. [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
</details> </details>
### Running Locally ### 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` 2. Start the application with `make run`
The application can also be tested from within a Docker container: 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 build -t siren:latest .
docker run --env-file .env -it --rm --name siren 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.

View File

@@ -8,7 +8,7 @@ name: siren
services: services:
bot: bot:
image: siren-service:${SIREN_VERSION:-latest} image: siren-service:${SIREN_VERSION:-latest}
container_name: siren-service container_name: siren-bot
build: build:
context: . context: .
dockerfile: ./Dockerfile dockerfile: ./Dockerfile
@@ -16,23 +16,16 @@ services:
- VERSION=${SIREN_VERSION:-latest} - VERSION=${SIREN_VERSION:-latest}
env_file: *env env_file: *env
environment: environment:
DATABASE_HOST: db DATABASE_HOST: postgres
DATABASE_PORT: 5432 DATABASE_PORT: 5432
REDIS_HOST: redis REDIS_HOST: redis
REDIS_PORT: 6379 REDIS_PORT: 6379
MINIO_HOST: minio
MINIO_PORT: 9000
SERVICE_HOST: service
SERVICE_PORT: 5000
DATA_DIR_PATH: /data DATA_DIR_PATH: /data
volumes: volumes:
- ${DATA_DIR_PATH:-/data}:/data - ${DATA_DIR_PATH:-~/data}:/data
ports:
- ${SERVICE_PORT:-5000}:5000
depends_on: depends_on:
- db - postgres
- redis - redis
- minio
networks: networks:
- frontend - frontend
- backend - backend