Navigation Menu

Skip to content

Commit

Permalink
Ensure the storage location resides in the Docker volume when required
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live committed Jun 7, 2018
1 parent ade3569 commit 9e07cc7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions Dockerfile
Expand Up @@ -19,6 +19,7 @@ ENV NODE_CONFIG_DIR=/data/config
ENV BOT_PORT=4501
ENV BOT_BIND=0.0.0.0
ENV BOT_DATABASE=/data/trello.db
ENV BOT_DATA_PATH=/data/storage
ENV BOT_DOCKER_LOGS=true

CMD node /matrix-trello-bot/index.js
Expand Down
3 changes: 3 additions & 0 deletions config/default.yaml
Expand Up @@ -14,6 +14,9 @@ publicBaseUrl: "https://your.domain.com"
# Where the database is located. Not used by the Docker image, and instead relies on the volume.
dbFile: "trello.db"

# Where sync data and other related information should be stored
dataPath: "./storage"

# Settings for controlling how logging works
# The Docker image will only consider the consoleLevel, and not write to any files.
logging:
Expand Down
10 changes: 10 additions & 0 deletions src/config.ts
Expand Up @@ -6,6 +6,7 @@ interface IConfig {
accessToken: string;

dbFile: string;
dataPath: string;

trelloApiKey: string;
trelloApiSecret: string;
Expand Down Expand Up @@ -46,6 +47,15 @@ if (process.env["BOT_DATABASE"]) {
conf.dbFile = readlDbPath;
}

if (process.env["BOT_DATA_PATH"]) {
const realPath = process.env["BOT_DATA_PATH"];
if (realPath !== conf.dataPath) {
console.warn("Configuration and environment variables do not agree on the data path. Using " + realPath);
}

conf.dataPath = realPath;
}

if (process.env["BOT_DOCKER_LOGS"]) {
console.log("Altering log configuration to only write out to console");
conf.logging = {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Expand Up @@ -7,7 +7,7 @@ import { CommandProcessor } from "./CommandProcessor";
import { WebhookProcessor } from "./notifications/WebhookProcessor";

LogService.configure(config.logging);
const storageProvider = new LocalstorageStorageProvider("./storage");
const storageProvider = new LocalstorageStorageProvider(config.dataPath);
const client = new MatrixClient(config.homeserverUrl, config.accessToken, storageProvider);
const commands = new CommandProcessor(client);
const processor = new WebhookProcessor(client);
Expand Down

0 comments on commit 9e07cc7

Please sign in to comment.