Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: Better handling of environment values in docker-compose usage #139

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# docker compose and/or something doesn't like ':' in keys!
# According to a comment on a SO question's comment
# (https://stackoverflow.com/questions/47827887/bash-zsh-export-environment-variable-with-name-containing-a-colon)
# this works in dotnet core! (not tested myself!)
# PLEASE don't use these kind of special characters in keys!

# providers:mastadon
providers__mastodon__BaseAddress=https://example.com

# providers:youtube
providers__youtube__ApiKey=

# providers:twitter
providers__twitter__DefaultHeaders__Authorization=Bearer $TOKEN
providers__twitter__ApiKey=
providers__twitter__ApiSecretKey=
providers__twitter__AccessToken=
providers__twitter__AccessTokenSecret=
18 changes: 18 additions & 0 deletions .env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# docker compose and/or something doesn't like ':' in keys!
# According to a comment on a SO question's comment
# (https://stackoverflow.com/questions/47827887/bash-zsh-export-environment-variable-with-name-containing-a-colon)
# this works in dotnet core! (not tested myself!)
# PLEASE don't use these kind of special characters in keys!

# providers:mastadon
providers__mastodon__BaseAddress=https://example-local.com

# providers:youtube
providers__youtube__ApiKey=

# providers:twitter
providers__twitter__DefaultHeaders__Authorization=Bearer $TOKEN
providers__twitter__ApiKey=
providers__twitter__ApiSecretKey=
providers__twitter__AccessToken=
providers__twitter__AccessTokenSecret=
8 changes: 5 additions & 3 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ TagzApp includes docker support and docker-compose files for easy deployment. Yo
git clone https://github.com/FritzAndFriends/TagzApp
cd TagzApp

# update docker-compose.yml as needed (custom API tokens, etc.)
# update primarily .env and docker-compose.yml as needed (custom API tokens, etc.)
docker compose -f docker-compose.yml up

```
Expand All @@ -97,7 +97,7 @@ docker compose -f docker-compose.yml up
git clone https://github.com/FritzAndFriends/TagzApp
cd TagzApp

# update docker-compose.local.yml as needed (custom API tokens, etc.)
# update primarily .env.local and docker-compose.local.yml as needed (custom API tokens, etc.)
docker compose -f docker-compose.local.yml up --build

# or
Expand All @@ -116,11 +116,13 @@ You don't *need* to override any configurations, the app will work out of the bo

In case you do have your own API keys or other values (see the the [`appsettings.json`](../src/TagzApp.Web/appsettings.json) for what can be supplied), then you can supply them like this:

* any [`appsettings.json`](../src/TagzApp.Web/appsettings.json) can be set in `.env` and `.env.local` files. Please set them this way: `key__subkey__property=value`. See the provided .env files for examples.

* from `docker-compose.yml` - use `key:subkey:property=value` syntax. See the docker-compose files for examples. Ex.

```
environment:
- providers:twitter:ApiKey=MySecretKey
```

* from `docker run` - use `-e "providers:twitter:ApiKey=MySecretKey"`. You need to repeat the `-e ` flag for each override.
* from `docker run` - use `-e "providers:twitter:ApiKey=MySecretKey"`. You need to repeat the `-e ` flag for each override.
15 changes: 5 additions & 10 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.7'
version: "3.7"
services:
web:
container_name: tagzapp.web
Expand All @@ -8,12 +8,7 @@ services:
context: .
ports:
- "80" # runs on a random local port. Change to "8080:80" if you want to run on localhost:8080

# environment:
# - providers:mastodon:BaseAddress=https://example.com
# - providers:youtube:ApiKey=
# - providers:twitter:DefaultHeaders:Authorization=Bearer $TOKEN
# - providers:twitter:ApiKey=
# - providers:twitter:ApiSecretKey=
# - providers:twitter:AccessToken=
# - providers:twitter:AccessTokenSecret=
env_file:
# when .env values are used in this docker-compose file like 'hostname: $hostname' for example it is strongly recommended to inject them by referencing them like 'docker compose up --env-file .env' or 'docker compose up --env-file .env.local'
- .env
- .env.local
12 changes: 4 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
version: '3.7'
version: "3.7"
services:
web:
container_name: tagzapp.web
hostname: tagzappweb
image: ghcr.io/fritzandfriends/tagzapp:latest
ports:
- "80" # runs on a random local port. Change to "8080:80" if you want to run on localhost:8080
# environment:
# - providers:youtube:ApiKey=
# - providers:twitter:DefaultHeaders:Authorization=Bearer $TOKEN
# - providers:twitter:ApiKey=
# - providers:twitter:ApiSecretKey=
# - providers:twitter:AccessToken=
# - providers:twitter:AccessTokenSecret=
env_file:
# when .env values are used in this docker-compose file like 'hostname: $hostname' for example it is strongly recommended to inject them by referencing them like 'docker compose up --env-file .env' or 'docker compose up --env-file .env.local'
- .env