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 support for docker compose secrets #430

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

simonrolfmore
Copy link

@simonrolfmore simonrolfmore commented Feb 8, 2025

This PR fixes #429.

Docker Compose supports secrets through mounting files in /run/secrets with appropriate permissions.

This is safer than passing them on the command line or directly through environment variables as it avoids the risk of the values showing up in execution history or logs.

Some other docker containers such as MySQL support this through the use of environment variable with _FILE appended, allowing for the variable to be set from a file rather than directly.

I have copied the same logic from the MySQL docker-entrypoint.sh, instead choosing to append _file as it fits Ghost's config variables better.

I have tested this with my own setup by swapping out the docker-entrypoint.sh file in docker compose, and selected the following variables for _file support:

  • database__connection__host
  • database__connection__user
  • database__connection__password
  • database__connection__database
  • mail__auth__user
  • mail__auth__pass

I hope this is useful to someone else, and I don't believe it adds unnecessary complexity to the containers, or removes any existing functionality.

Docker Compose supports [secrets](https://docs.docker.com/compose/how-tos/use-secrets/) through mounting files in `run/secrets` with appropriate permissions.

This is safer than passing them on the command line or directly through environment variables as it avoids the risk of the values showing up in execution history or logs.

Some other docker containers such as [MySQL](https://hub.docker.com/_/mysql) support this through the use of environment variable with `_FILE` appended, allowing for the variable to be set from a file rather than directly.

I have copied the same logic from the MySQL `docker-entrypoint.sh`, instead choosing to append `_file` as it fits Ghost's config variables better.

I have tested this with my own setup by swapping out the `docker-entrypoint.sh` file in docker compose, and selected the following variables for `_file` support:

- `database__connection__host`
- `database__connection__user`
- `database__connection__password`
- `database__connection__database`
- `mail__auth__user`
- `mail__auth__pass`

I hope this is useful to someone else, and I don't believe it adds unnecessary complexity to the containers, or removes any existing functionality.
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.

Add support for Docker Compose secrets
1 participant