Apply suggestions from code review
Co-authored-by: Márk Sági-Kazár <sagikazarmark@users.noreply.github.com> Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
This commit is contained in:
parent
7f744598f5
commit
dd4a62e645
11
Dockerfile
11
Dockerfile
@ -25,7 +25,8 @@ FROM alpine:3.13.1 AS gomplate
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
ARG TARGETVARIANT
|
||||
ARG GOMPLATE_VERSION=v3.9.0
|
||||
|
||||
ENV GOMPLATE_VERSION=v3.9.0
|
||||
|
||||
RUN wget -O /usr/local/bin/gomplate \
|
||||
"https://github.com/hairyhenderson/gomplate/releases/download/${GOMPLATE_VERSION}/gomplate_${TARGETOS:-linux}-${TARGETARCH:-amd64}${TARGETVARIANT}" \
|
||||
@ -45,7 +46,7 @@ RUN mkdir -p /var/dex
|
||||
RUN chown -R 1001:1001 /var/dex
|
||||
|
||||
RUN mkdir -p /etc/dex
|
||||
COPY config.docker.yaml /etc/dex/config.docker.yaml
|
||||
COPY config.docker.yaml /etc/dex/
|
||||
RUN chown -R 1001:1001 /etc/dex
|
||||
|
||||
# Copy module files for CVE scanning / dependency analysis.
|
||||
@ -63,7 +64,7 @@ COPY --from=builder /usr/local/src/dex/web /web
|
||||
|
||||
USER 1001:1001
|
||||
|
||||
COPY docker-entrypoint.sh /
|
||||
COPY docker-entrypoint.sh /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
CMD ["serve", "/etc/dex/config.docker.yaml"]
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
CMD ["dex", "serve", "/etc/dex/config.docker.yaml"]
|
||||
|
@ -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"
|
||||
|
||||
args="${args} ${tmpfile}"
|
||||
else
|
||||
args="${args} ${file_candidate}"
|
||||
fi
|
||||
done
|
||||
exec dex $args
|
||||
;;
|
||||
--help|-h|version)
|
||||
exec dex $@
|
||||
;;
|
||||
*)
|
||||
if [[ "$executable" != "dex" ]] && [[ "$executable" != "$(which dex)" ]]; then
|
||||
exec $@
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [[ "$command" != "serve" ]]; then
|
||||
exec $@
|
||||
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 $@
|
||||
|
Reference in New Issue
Block a user