-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Márk Sági-Kazár <[email protected]> Signed-off-by: m.nabokikh <[email protected]>
- Loading branch information
1 parent
7f74459
commit dd4a62e
Showing
2 changed files
with
32 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,32 @@ | ||
#!/bin/sh -e | ||
|
||
### Usage: /docker-entrypoint.sh <command> <args> | ||
### * If command equals to "serve", config file for serving will be preprocessed using gomplate and saved to tmp dir. | ||
### Example: docker-entrypoint.sh serve config.yaml = dex serve /tmp/dex-config.yaml-ABCDEFG | ||
### * If command is not in the list of known dex commands, it will be executed bypassing entrypoint. | ||
### Example: docker-entrypoint.sh echo "Hello!" = echo "Hello!" | ||
function main() { | ||
executable=$1 | ||
command=$2 | ||
|
||
command=$1 | ||
|
||
case "$command" in | ||
serve) | ||
for file_candidate in $@ ; do | ||
if test -f "$file_candidate"; then | ||
tmpfile=$(mktemp /tmp/dex.config.yaml-XXXXXX) | ||
gomplate -f "$file_candidate" -o "$tmpfile" | ||
if [[ "$executable" != "dex" ]] && [[ "$executable" != "$(which dex)" ]]; then | ||
exec $@ | ||
fi | ||
|
||
args="${args} ${tmpfile}" | ||
else | ||
args="${args} ${file_candidate}" | ||
fi | ||
done | ||
exec dex $args | ||
;; | ||
--help|-h|version) | ||
exec dex $@ | ||
;; | ||
*) | ||
if [[ "$command" != "serve" ]]; then | ||
exec $@ | ||
;; | ||
esac | ||
fi | ||
|
||
for tpl_candidate in $@ ; do | ||
case "$tpl_candidate" in | ||
*.tpl|*.tmpl|*.yaml) | ||
tmp_file=$(mktemp /tmp/dex.config.yaml-XXXXXX) | ||
gomplate -f "$tpl_candidate" -o "$tmp_file" | ||
|
||
args="${args} ${tmp_file}" | ||
;; | ||
*) | ||
args="${args} ${tpl_candidate}" | ||
;; | ||
esac | ||
done | ||
exec $args | ||
} | ||
|
||
main $@ |