From 3d7a85843fc4c8028ac87a0e5df98c477f2fffc1 Mon Sep 17 00:00:00 2001 From: JoaoCostaIFG Date: Sat, 6 Jul 2024 01:01:39 +0100 Subject: [PATCH 1/4] Feat: allow users to change dotenv file with env var This facilitates the usage of docker secrets for the keys/tokens. --- src/services/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/config.ts b/src/services/config.ts index b6b9aea..019df07 100644 --- a/src/services/config.ts +++ b/src/services/config.ts @@ -5,7 +5,7 @@ import path from 'path'; import xbytes from 'xbytes'; import {ConditionalKeys} from 'type-fest'; import {ActivityType, PresenceStatusData} from 'discord.js'; -dotenv.config(); +dotenv.config({path: process.env.ENV_FILE ?? path.resolve(process.cwd(), '.env')}); export const DATA_DIR = path.resolve(process.env.DATA_DIR ? process.env.DATA_DIR : './data'); From 18e5c5c80e2ff205d46420d9760d9b9d9e824f00 Mon Sep 17 00:00:00 2001 From: JoaoCostaIFG Date: Mon, 28 Oct 2024 16:07:55 +0000 Subject: [PATCH 2/4] Feat: default ENV_FILE to /config in dockerfile --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index dc21173..1bde8fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -53,5 +53,6 @@ ENV DATA_DIR /data ENV NODE_ENV production ENV COMMIT_HASH $COMMIT_HASH ENV BUILD_DATE $BUILD_DATE +ENV ENV_FILE /config CMD ["tini", "--", "node", "--enable-source-maps", "dist/scripts/migrate-and-start.js"] From ae40463712875613c7d485264d61a7965df8a57d Mon Sep 17 00:00:00 2001 From: JoaoCostaIFG Date: Mon, 28 Oct 2024 16:15:29 +0000 Subject: [PATCH 3/4] Doc: document the existance and usage of ENV_FILe env var. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e4f1f25..9b81f22 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,8 @@ docker run -it -v "$(pwd)/data":/data -e DISCORD_TOKEN='' -e SPOTIFY_CLIENT_ID=' This starts Muse and creates a data directory in your current directory. +You can also store your tokens in an environment file and make it available to your container. By default, the container will look for a `/config` environment file. You can customize this path with the `ENV_FILE` environment variable to use with, for example, [docker secrets](https://docs.docker.com/engine/swarm/secrets/). + **Docker Compose**: ```yaml From c954cccacbf9f4aaf911b9a232a8dec8117af932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Costa?= Date: Mon, 28 Oct 2024 22:36:17 +0000 Subject: [PATCH 4/4] Fix: legacy env key in dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7cd7037..82f051f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,6 +52,6 @@ ENV DATA_DIR=/data ENV NODE_ENV=production ENV COMMIT_HASH=$COMMIT_HASH ENV BUILD_DATE=$BUILD_DATE -ENV ENV_FILE /config +ENV ENV_FILE=/config CMD ["tini", "--", "node", "--enable-source-maps", "dist/scripts/migrate-and-start.js"]