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

Adding support for docker secrets #93

Merged
merged 3 commits into from
Jan 12, 2022
Merged

Conversation

DennisGaida
Copy link
Contributor

Added some code in all entrypoints to support docker secrets (https://docs.docker.com/engine/swarm/secrets/) as requested here: monicahq/monica#5809

Instead of supporting secrets (chosen naming convention is <environment variable name> + _FILE suffix, e.g. DB_PASSWORD_FILE - some containers use __FILE) for all environment variables, a set of supported secrets is defined in supportedSecrets. Then it is checked whether the environment variable with the suffix exists and whether the secrets file exists.

If all checks pass, the original environment variable is overwritten with the contents contained in the secrets file.

It can be tested with the following example docker-compose.yml:

secrets:
  monicahq_db_password:
    file: $SECRETSDIR/monicahq_db_password

services:
  monicahq:
    image: monica
    container_name: monica
    environment:
      - DB_PASSWORD_FILE=/run/secrets/monicahq_db_pasword
    secrets:
      - monicahq_db_password

I haven't updated the docker-compose.yml examples as I first want to check the waters.

@asbiin asbiin merged commit d6d6c22 into monicahq:master Jan 12, 2022
@asbiin
Copy link
Member

asbiin commented Jan 12, 2022

That's really great @DennisGaida ! Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants