diff --git a/Dockerfile b/Dockerfile index 328c7d9..82f051f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,5 +52,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"] diff --git a/README.md b/README.md index 7fec19f..b21bb52 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,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 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');