Reviewed docker entrypoint files for Alpine images and introduced CMD

This commit is contained in:
Alexey Pustovalov
2019-10-03 17:08:57 +03:00
parent c593d36151
commit d4246a2708
16 changed files with 98 additions and 201 deletions

View File

@ -38,6 +38,7 @@ RUN set -eux && \
autoconf \
automake \
coreutils \
pkgconf \
git \
g++ \
make \
@ -76,3 +77,7 @@ COPY ["conf/usr/sbin/zabbix_java_gateway", "/usr/sbin/"]
COPY ["docker-entrypoint.sh", "/usr/bin/"]
ENTRYPOINT ["docker-entrypoint.sh"]
USER zabbix
CMD ["/usr/sbin/zabbix_java_gateway"]

View File

@ -1,6 +1,6 @@
#!/bin/bash
set -eo pipefail
set -o pipefail
set +e
@ -13,37 +13,6 @@ fi
# Configuration files directory
ZABBIX_ETC_DIR="/etc/zabbix"
# usage: file_env VAR [DEFAULT]
# as example: file_env 'MYSQL_PASSWORD' 'zabbix'
# (will allow for "$MYSQL_PASSWORD_FILE" to fill in the value of "$MYSQL_PASSWORD" from a file)
# unsets the VAR_FILE afterwards and just leaving VAR
file_env() {
local var="$1"
local fileVar="${var}_FILE"
local defaultValue="${2:-}"
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
echo "**** Both variables $var and $fileVar are set (but are exclusive)"
exit 1
fi
local val="$defaultValue"
if [ "${!var:-}" ]; then
val="${!var}"
echo "** Using ${var} variable from ENV"
elif [ "${!fileVar:-}" ]; then
if [ ! -f "${!fileVar}" ]; then
echo "**** Secret file \"${!fileVar}\" is not found"
exit 1
fi
val="$(< "${!fileVar}")"
echo "** Using ${var} variable from secret file"
fi
export "$var"="$val"
unset "$fileVar"
}
escape_spec_char() {
local var_value=$1
@ -152,12 +121,7 @@ prepare_java_gateway
echo "########################################################"
if [ "$1" != "" ]; then
echo "** Executing '$@'"
exec "$@"
else
echo "** Starting Zabbix Java Gateway"
exec su zabbix -s "/bin/bash" -c "/usr/sbin/zabbix_java_gateway"
fi
echo "** Executing '$@'"
exec "$@"
#################################################