Skip to content

Commit

Permalink
fix: 開発環境で起動できない問題の修正 (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
m1sk9 authored Sep 2, 2024
1 parent 9085fff commit e7b5d14
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Discord API のトークンを指定する
# Configuration file path (relative path)
CONFIG_FILE_PATH=
# Discord API token
DISCORD_API_TOKEN=
10 changes: 6 additions & 4 deletions docs/src/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@

Key whose `Required` column is `Yes` must be specified. If not specified, babyrite will not start correctly.

| Key | Description | Required | Default |
|---------------------|-------------------|----------|---------|
| `DISCORD_API_TOKEN` | Discord API Token | Yes | --- |
| Key | Description | Required | Default |
|---------------------|-----------------------------------------|----------|---------|
| `CONFIG_FILE_PATH` | Configuration file path (relative path) | No | --- |
| `DISCORD_API_TOKEN` | Discord API Token | Yes | --- |

3. Copy configuration files:

Expand All @@ -35,7 +36,7 @@
4. Start babyrite:

```sh
docker run -e DISCORD_API_TOKEN=your_discord_api_token --volume ./config/config.yaml:/config/config.yaml ghcr.io/m1sk9/babyrite
docker run -e CONFIG_FILE_PATH=/path/to/your/config.yaml -e DISCORD_API_TOKEN=your_discord_api_token --volume ./config/config.yaml:/config/config.yaml ghcr.io/m1sk9/babyrite
```

## Using Docker Compose
Expand All @@ -58,6 +59,7 @@
2. Create a `.env` file:

```sh
CONFIG_FILE_PATH=/path/to/your/config.yaml
DISCORD_API_TOKEN=your_discord_api_token
```

Expand Down
1 change: 1 addition & 0 deletions src/env.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#[derive(serde::Deserialize)]
pub struct BabyriteEnv {
pub config_file_path: String,
pub discord_api_token: String,
}

Expand Down
4 changes: 3 additions & 1 deletion src/model/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use serde::Deserialize;

use crate::env::babyrite_envs;

#[derive(Debug, Deserialize)]
pub struct BabyriteConfig {
pub bypass_guilds: bool,
Expand All @@ -13,7 +15,7 @@ impl BabyriteConfig {
BABYRITE_CONFIG
.set(
serde_yaml::from_reader(std::io::BufReader::new(
std::fs::File::open("/config/config.yaml")
std::fs::File::open(&babyrite_envs().config_file_path)
.expect("Failed to open configuration file."),
))
.expect("Failed to parse config.yaml. Please check if the settings are correct."),
Expand Down

0 comments on commit e7b5d14

Please sign in to comment.