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 postgres docker-compose file #308

Merged
merged 4 commits into from
Sep 27, 2024

Conversation

woernsn
Copy link
Contributor

@woernsn woernsn commented Sep 26, 2024

Restructure the existing sqlite docker-compose yaml file and add an additional docker-compose file for postgres.

Also update the README accordingly.

Restructure the existing sqlite docker-compose yaml file and add an additional docker-compose file for postgres.

Also update the README accordingly.
Copy link
Owner

@jovandeginste jovandeginste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the contribution; should we not use an env_file instead of expecting environment variables?

@woernsn
Copy link
Contributor Author

woernsn commented Sep 26, 2024

I appreciate the contribution; should we not use an env_file instead of expecting environment variables?

The env file would need to be loaded by the calling sh/bash then.
The issue here is that we "need" the parameters during build time whereas the env_file parameters are only available during runtime.

The alternative would be to not use environment variables and setting the strings in the compose files directly. But then we would need to copy/paste strings (once for the DSN string and once for the DB container's env and/or health check).

BTW, I will check the formatting issues asap!

@jovandeginste
Copy link
Owner

I'm not sure what you mean by "build time"; I was referring to this feature in docker compose: https://docker.qubitpi.org/compose/environment-variables/set-environment-variables/#use-the-env_file-attribute

I use this for keeping secrets away from the compose files, and keeping the compose files in git.

@woernsn
Copy link
Contributor Author

woernsn commented Sep 27, 2024

Sorry, I wasn't aware that the go module for postgres can handle environment variables at runtime.

The difference: If setting the environment variable in bash, the variables would already be replaced at buildtime (when running docker compose up / docker build).
With the env_file approach, the environment variables are only set for the container on runtime (when running docker compose start / docker run).

I quickly tested the runtime approach and it seems to be handled correctly by go.
Therefore your suggestion is valid and makes totally sense. 🚀

@jovandeginste jovandeginste merged commit b8ac078 into jovandeginste:master Sep 27, 2024
2 checks passed
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