From 7244ab2eec2efce36d50272168e1eae5992d85bc Mon Sep 17 00:00:00 2001 From: Irfan Radzi Date: Thu, 26 Sep 2019 14:31:46 +0800 Subject: [PATCH] Environment variables to use .env instead of manually exporting it --- .env-example | 12 ++++++++++++ .gitignore | 2 ++ README.md | 8 ++------ docker-compose.yml | 40 ++++++++++++++++++++-------------------- 4 files changed, 36 insertions(+), 26 deletions(-) create mode 100644 .env-example create mode 100644 .gitignore diff --git a/.env-example b/.env-example new file mode 100644 index 0000000..17ce233 --- /dev/null +++ b/.env-example @@ -0,0 +1,12 @@ +INTEGRAM_PORT=7000 +INTEGRAM_BASE_URL=localhost +TRELLO_BOT_TOKEN= +TRELLO_OAUTH_ID= +TRELLO_OAUTH_SECRET= +GITLAB_BOT_TOKEN= +GITLAB_OAUTH_ID= +GITLAB_OAUTH_SECRET= +BITBUCKET_BOT_TOKEN= +BITBUCKET_OAUTH_ID= +BITBUCKET_OAUTH_SECRET= +WEBHOOK_BOT_TOKEN= \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..66ac529 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.env +DS_Store \ No newline at end of file diff --git a/README.md b/README.md index 8209a43..f8a8288 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ How to host Integram on your own server (using your private bots) ```bash git clone https://github.com/requilence/integram && cd integram ``` -- Check the `docker-compose.yml` file for the required ENV vars for each service +- Check the `.env-example` file for the required ENV vars for each service - E.g. in order to run the Trello integration you will need to export: - **INTEGRAM_BASE_URL** – the base URL where your Integram host will be accessible, e.g. **https://integram.org** - **INTEGRAM_PORT** – if set to 443 Integram will use ssl.key/ssl.cert at /go/.conf. @@ -49,11 +49,7 @@ How to host Integram on your own server (using your private bots) - **TRELLO_OAUTH_SECRET** – OAuth Secret - For more detailed info about other services you should check the corresponding repo at https://github.com/integram-org -- Export the variables you identified in the previous step, for instance on linux this should be something like: -```bash - export INTEGRAM_PORT=xxxx - export ... -``` +- Create a new file from `.env-example` and name it `.env`. Update the variables as necessary. [Read more about `.env` and `docker-compose`](https://docs.docker.com/compose/compose-file/#variable-substitution) - Now you can run the services (linux: careful if you need to sudo this, the exports you just did will not be available) : ```bash docker-compose -p integram up trello gitlab ## Here you specify the services you want to run diff --git a/docker-compose.yml b/docker-compose.yml index 673a4b1..16f5d34 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -39,8 +39,8 @@ services: - INTEGRAM_INSTANCE_MODE=multi-main - INTEGRAM_CONFIG_DIR=/app/.conf ## required ENV vars - - INTEGRAM_PORT - - INTEGRAM_BASE_URL + - INTEGRAM_PORT=${INTEGRAM_PORT} + - INTEGRAM_BASE_URL=${INTEGRAM_BASE_URL} trello: image: integram/trello:latest restart: always @@ -51,16 +51,16 @@ services: - integram environment: - TZ=UTC - - INTEGRAM_PORT=7000 + - INTEGRAM_PORT=${INTEGRAM_PORT} - INTEGRAM_MONGO_URL=mongodb://mongo:27017/integram - INTEGRAM_REDIS_URL=redis:6379 - INTEGRAM_INSTANCE_MODE=multi-service ## required ENV vars - - INTEGRAM_BASE_URL - - TRELLO_BOT_TOKEN - - TRELLO_OAUTH_ID - - TRELLO_OAUTH_SECRET + - INTEGRAM_BASE_URL=${INTEGRAM_BASE_URL} + - TRELLO_BOT_TOKEN=${TRELLO_BOT_TOKEN} + - TRELLO_OAUTH_ID=${TRELLO_OAUTH_ID} + - TRELLO_OAUTH_SECRET=${TRELLO_OAUTH_SECRET} gitlab: image: integram/gitlab restart: always @@ -71,16 +71,16 @@ services: - integram environment: - TZ=UTC - - INTEGRAM_PORT=7000 + - INTEGRAM_PORT=${INTEGRAM_PORT} - INTEGRAM_MONGO_URL=mongodb://mongo:27017/integram - INTEGRAM_REDIS_URL=redis:6379 - INTEGRAM_INSTANCE_MODE=multi-service ## required ENV vars - - INTEGRAM_BASE_URL - - GITLAB_BOT_TOKEN - - GITLAB_OAUTH_ID - - GITLAB_OAUTH_SECRET + - INTEGRAM_BASE_URL=${INTEGRAM_BASE_URL} + - GITLAB_BOT_TOKEN=${GITLAB_BOT_TOKEN} + - GITLAB_OAUTH_ID=${GITLAB_OAUTH_ID} + - GITLAB_OAUTH_SECRET=${GITLAB_OAUTH_SECRET} bitbucket: image: integram/bitbucket restart: always @@ -91,16 +91,16 @@ services: - integram environment: - TZ=UTC - - INTEGRAM_PORT=7000 + - INTEGRAM_PORT=${INTEGRAM_PORT} - INTEGRAM_MONGO_URL=mongodb://mongo:27017/integram - INTEGRAM_REDIS_URL=redis:6379 - INTEGRAM_INSTANCE_MODE=multi-service ## required ENV vars - - INTEGRAM_BASE_URL - - BITBUCKET_BOT_TOKEN - - BITBUCKET_OAUTH_ID - - BITBUCKET_OAUTH_SECRET + - INTEGRAM_BASE_URL=${INTEGRAM_BASE_URL} + - BITBUCKET_BOT_TOKEN=${BITBUCKET_BOT_TOKEN} + - BITBUCKET_OAUTH_ID=${BITBUCKET_OAUTH_ID} + - BITBUCKET_OAUTH_SECRET=${BITBUCKET_OAUTH_SECRET} webhook: image: integram/webhook restart: always @@ -111,11 +111,11 @@ services: - integram environment: - TZ=UTC - - INTEGRAM_PORT=7000 + - INTEGRAM_PORT=${INTEGRAM_PORT} - INTEGRAM_MONGO_URL=mongodb://mongo:27017/integram - INTEGRAM_REDIS_URL=redis:6379 - INTEGRAM_INSTANCE_MODE=multi-service ## required ENV vars - - INTEGRAM_BASE_URL - - WEBHOOK_BOT_TOKEN + - INTEGRAM_BASE_URL=${INTEGRAM_BASE_URL} + - WEBHOOK_BOT_TOKEN=${WEBHOOK_BOT_TOKEN}