feat(backend): allow to define path to the config file (#838)

Allow to configure where the configuration file is located via the `CONFIG_FILE` environment variable

Co-authored-by: Jules Lefebvre <jules.lefebvre@diabolocom.com>
This commit is contained in:
JulesdeCube
2025-05-19 15:30:06 +02:00
committed by GitHub
parent 18b34e9bf2
commit cfdb29ed4d
3 changed files with 5 additions and 1 deletions

View File

@@ -13,6 +13,7 @@ import { PrismaService } from "src/prisma/prisma.service";
import { stringToTimespan } from "src/utils/date.util";
import { parse as yamlParse } from "yaml";
import { YamlConfig } from "../../prisma/seed/config.seed";
import { CONFIG_FILE } from "src/constants";
/**
* ConfigService extends EventEmitter to allow listening for config updates,
@@ -42,7 +43,7 @@ export class ConfigService extends EventEmitter {
private async loadYamlConfig() {
let configFile: string = "";
try {
configFile = fs.readFileSync("../config.yaml", "utf8");
configFile = fs.readFileSync(CONFIG_FILE, "utf8");
} catch (e) {
this.logger.log(
"Config.yaml is not set. Falling back to UI configuration.",

View File

@@ -1,5 +1,7 @@
import { LogLevel } from "@nestjs/common";
export const CONFIG_FILE = process.env.CONFIG_FILE || "../config.yaml";
export const DATA_DIRECTORY = process.env.DATA_DIRECTORY || "./data";
export const SHARE_DIRECTORY = `${DATA_DIRECTORY}/uploads/shares`;
export const DATABASE_URL =

View File

@@ -33,6 +33,7 @@ For installation specific configuration, you can use environment variables. The
| `BACKEND_PORT` | `8080` | The port on which the backend listens. |
| `DATABASE_URL` | `file:../data/pingvin-share.db?connection_limit=1` | The URL of the SQLite database. |
| `DATA_DIRECTORY` | `./data` | The directory where data is stored. |
| `CONFIG_FILE` | `../config.yaml` | Path to the configuration file |
| `CLAMAV_HOST` | `127.0.0.1` or `clamav` when running with Docker | The IP address of the ClamAV server. See the [ClamAV docs](integrations.md#clamav) for more information. |
| `CLAMAV_PORT` | `3310` | The port number of the ClamAV server. |