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

[Suggestion] Use gomplate instead of sed #5

Open
zicklag opened this issue Sep 27, 2018 · 1 comment
Open

[Suggestion] Use gomplate instead of sed #5

zicklag opened this issue Sep 27, 2018 · 1 comment

Comments

@zicklag
Copy link
Contributor

zicklag commented Sep 27, 2018

Hi @tiredofit,

I was trying out your container and I noticed that you use sed to substitute the environment variables into the SSP config template file. I just wanted to let you know about an awesome tool called Gomplate that could make that process a whole lot cleaner and more elegant IMHO.

You can use the Go template format for your config template then substitute the values straight from the container environment variables with a single command, using Gomplate ( a 4.51MB binary ). It is very nice. I just used it in my own SSP container:

config.inc.local.php.template:

...
# LDAP
$ldap_url = "{{.Env.LDAP_URL}}";
$ldap_starttls = {{.Env.LDAP_STARTTLS}};
$ldap_binddn = "{{.Env.LDAP_BINDDN}}";
$ldap_bindpw = "{{.Env.LDAP_BINDPW}}";
$ldap_base = "{{.Env.LDAP_BASE}}";
$ldap_login_attribute = "{{.Env.LDAP_LOGIN_ATTRIBUTE}}";
$ldap_fullname_attribute = "{{.Env.LDAP_FULLNAME_ATTRIBUTE}}";
{{if not .Env.LDAP_FILTER}}
$ldap_filter = "(&(objectClass={{.Env.LDAP_OBJECT_CLASS}})($ldap_login_attribute={login}}))";
{{else}}
$ldap_filter = "{{.Env.LDAP_FILTER}}";
{{end}}
...

Having if statements and other functions lets you add logic like I did with the LDAP_FILTER variable. Very cool.

Anyway, that's just my tip from one Docker geek to another. Hope you enjoy. 😃

@fbartels
Copy link

fbartels commented Jan 4, 2019

An alternative to gomplate could be https://github.com/jwilder/dockerize

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

No branches or pull requests

2 participants