Skip to content

Commit cfdb29e

Browse files
JulesdeCubeJules Lefebvre
andauthored
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 <[email protected]>
1 parent 18b34e9 commit cfdb29e

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

backend/src/config/config.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { PrismaService } from "src/prisma/prisma.service";
1313
import { stringToTimespan } from "src/utils/date.util";
1414
import { parse as yamlParse } from "yaml";
1515
import { YamlConfig } from "../../prisma/seed/config.seed";
16+
import { CONFIG_FILE } from "src/constants";
1617

1718
/**
1819
* ConfigService extends EventEmitter to allow listening for config updates,
@@ -42,7 +43,7 @@ export class ConfigService extends EventEmitter {
4243
private async loadYamlConfig() {
4344
let configFile: string = "";
4445
try {
45-
configFile = fs.readFileSync("../config.yaml", "utf8");
46+
configFile = fs.readFileSync(CONFIG_FILE, "utf8");
4647
} catch (e) {
4748
this.logger.log(
4849
"Config.yaml is not set. Falling back to UI configuration.",

backend/src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { LogLevel } from "@nestjs/common";
22

3+
export const CONFIG_FILE = process.env.CONFIG_FILE || "../config.yaml";
4+
35
export const DATA_DIRECTORY = process.env.DATA_DIRECTORY || "./data";
46
export const SHARE_DIRECTORY = `${DATA_DIRECTORY}/uploads/shares`;
57
export const DATABASE_URL =

docs/docs/setup/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ For installation specific configuration, you can use environment variables. The
3333
| `BACKEND_PORT` | `8080` | The port on which the backend listens. |
3434
| `DATABASE_URL` | `file:../data/pingvin-share.db?connection_limit=1` | The URL of the SQLite database. |
3535
| `DATA_DIRECTORY` | `./data` | The directory where data is stored. |
36+
| `CONFIG_FILE` | `../config.yaml` | Path to the configuration file |
3637
| `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. |
3738
| `CLAMAV_PORT` | `3310` | The port number of the ClamAV server. |
3839

0 commit comments

Comments
 (0)