Skip to content

Commit

Permalink
Removed supervisord from single application images
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Feb 22, 2018
1 parent cfcad63 commit 6a382c3
Show file tree
Hide file tree
Showing 108 changed files with 1,415 additions and 1,766 deletions.
16 changes: 7 additions & 9 deletions agent/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ ARG VCS_REF
ARG APK_FLAGS_COMMON="-q"
ARG APK_FLAGS_PERSISTANT="${APK_FLAGS_COMMON} --clean-protected --no-cache"
ARG APK_FLAGS_DEV="${APK_FLAGS_COMMON} --no-cache"
ENV TERM=xterm
ENV TERM=xterm \
ZBX_TYPE=agent ZBX_DB_TYPE=none ZBX_OPT_TYPE=none

LABEL org.label-schema.name="zabbix-agent-alpine" \
LABEL org.label-schema.name="zabbix-${ZBX_TYPE}-alpine" \
org.label-schema.vendor="Zabbix LLC" \
org.label-schema.url="https://zabbix.com/" \
org.label-schema.description="Zabbix agent is deployed on a monitoring target to actively monitor local resources and applications" \
Expand All @@ -35,8 +36,7 @@ RUN addgroup zabbix && \
apk add ${APK_FLAGS_PERSISTANT} \
bash \
iputils \
libldap \
supervisor && \
libldap && \
rm -rf /var/cache/apk/*

ARG MAJOR_VERSION=master
Expand All @@ -47,7 +47,7 @@ ENV ZBX_VERSION=${ZBX_VERSION} ZBX_SOURCES=${ZBX_SOURCES}
LABEL org.label-schema.usage="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" \
org.label-schema.version="${ZBX_VERSION}" \
org.label-schema.vcs-url="${ZBX_SOURCES}" \
org.label-schema.docker.cmd="docker run --name zabbix-agent --link zabbix-server:zabbix-server -p 10050:10050 -d zabbix-agent:alpine-${ZBX_VERSION}"
org.label-schema.docker.cmd="docker run --name zabbix-${ZBX_TYPE} --link zabbix-server:zabbix-server -p 10050:10050 -d zabbix-${ZBX_TYPE}:alpine-${ZBX_VERSION}"

RUN apk update && \
apk add ${APK_FLAGS_DEV} --virtual build-dependencies \
Expand Down Expand Up @@ -87,17 +87,15 @@ RUN apk update && \
apk del ${APK_FLAGS_COMMON} --purge \
build-dependencies && \
rm -rf /var/cache/apk/* && \
rm -rf /root/.subversion
rm -rf /root/.subversion && \
rm -rf /var/svn

EXPOSE 10050/TCP

WORKDIR /var/lib/zabbix

VOLUME ["/etc/zabbix/zabbix_agentd.d", "/var/lib/zabbix/enc", "/var/lib/zabbix/modules"]

COPY ["conf/etc/supervisor/", "/etc/supervisor/"]
COPY ["docker-entrypoint.sh", "/usr/bin/"]

ENTRYPOINT ["docker-entrypoint.sh"]

CMD ["agentd", "none"]
17 changes: 0 additions & 17 deletions agent/alpine/conf/etc/supervisor/conf.d/supervisord_zabbix.conf

This file was deleted.

35 changes: 0 additions & 35 deletions agent/alpine/conf/etc/supervisor/supervisord.conf

This file was deleted.

46 changes: 38 additions & 8 deletions agent/alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ fi

# Type of Zabbix component
# Possible values: [server, proxy, agent, web, dev]
zbx_type="$1"
zbx_type=${ZBX_TYPE}
# Type of Zabbix database
# Possible values: [mysql, postgresql]
zbx_db_type="$2"
zbx_db_type=${ZBX_DB_TYPE}
# Type of web-server. Valid only with zbx_type = web
# Possible values: [apache, nginx]
zbx_opt_type="$3"
zbx_opt_type=${ZBX_OPT_TYPE}

# Default Zabbix installation name
# Used only by Zabbix web-interface
Expand Down Expand Up @@ -872,8 +872,8 @@ else
exit 1
fi

if [ -n "$zbx_db_type" ]; then
if [ -n "$zbx_opt_type" ]; then
if [ "$zbx_db_type" != "none" ]; then
if [ "$zbx_opt_type" != "none" ]; then
echo "** Deploying Zabbix $zbx_type ($zbx_opt_type) with $zbx_db_type database"
else
echo "** Deploying Zabbix $zbx_type with $zbx_db_type database"
Expand All @@ -894,7 +894,7 @@ prepare_system "$zbx_type" "$zbx_opt_type"
[ "$zbx_type" == "frontend" ] && prepare_web $zbx_opt_type $zbx_db_type
[ "${ZBX_ADD_WEB}" == "true" ] && prepare_web ${ZBX_WEB_SERVER} ${ZBX_MAIN_DB}

[ "$zbx_type" == "agentd" ] && prepare_agent
[ "$zbx_type" == "agent" ] && prepare_agent
[ "${ZBX_ADD_AGENT}" == "true" ] && prepare_agent

[ "$zbx_type" == "java-gateway" ] && prepare_java_gateway
Expand All @@ -904,7 +904,37 @@ clear_deploy "$zbx_type"

echo "########################################################"

echo "** Executing supervisord"
exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
if [ "$1" != "" ]; then
echo "** Executing '$@'"
exec "$@"
elif [ "$zbx_type" == "agent" ]; then
echo "** Starting Zabbix agent"
exec su zabbix -s "/bin/bash" -c "/usr/sbin/zabbix_agentd --foreground -c /etc/zabbix/zabbix_agentd.conf"
elif [ "$zbx_type" == "proxy" ]; then
echo "** Starting Zabbix proxy"
exec su zabbix -s "/bin/bash" -c "/usr/sbin/zabbix_proxy --foreground -c /etc/zabbix/zabbix_proxy.conf"
elif [ "$zbx_type" == "server" ]; then
echo "** Starting Zabbix server"
exec su zabbix -s "/bin/bash" -c "/usr/sbin/zabbix_server --foreground -c /etc/zabbix/zabbix_server.conf"
elif [ "$zbx_type" == "java-gateway" ]; then
echo "** Starting Zabbix Java Gateway"
exec su zabbix -s "/bin/bash" -c "/usr/sbin/zabbix_java_gateway"
elif [ "$zbx_type" == "frontend" ] && [ "$zbx_opt_type" == "apache" ]; then
echo "** Starting Zabbix frontend"
if [ -f "/usr/sbin/httpd" ]; then
exec /usr/sbin/httpd -D FOREGROUND
elif [ -f "/usr/sbin/apache2ctl" ]; then
exec source /etc/apache2/envvars && /usr/sbin/apache2ctl -D FOREGROUND
else
echo "Unknown Web-server. Exiting..."
exit 1
fi
elif [ -f "/usr/bin/supervisord" ]; then
echo "** Executing supervisord"
exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
else
echo "Unknown instructions. Exiting..."
exit 1
fi

#################################################
14 changes: 5 additions & 9 deletions agent/centos/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ ARG VCS_REF
ARG YUM_FLAGS_COMMON="--quiet -y"
ARG YUM_FLAGS_PERSISTANT="${YUM_FLAGS_COMMON}"
ARG YUM_FLAGS_DEV="${YUM_FLAGS_COMMON}"
ENV TERM=xterm
ENV TERM=xterm \
ZBX_TYPE=agent ZBX_DB_TYPE=none ZBX_OPT_TYPE=none

LABEL org.label-schema.name="zabbix-agent-centos" \
LABEL org.label-schema.name="zabbix-${ZBX_TYPE}-centos" \
org.label-schema.vendor="Zabbix LLC" \
org.label-schema.url="https://zabbix.com/" \
org.label-schema.description="Zabbix agent is deployed on a monitoring target to actively monitor local resources and applications" \
Expand All @@ -32,11 +33,9 @@ RUN groupadd --system zabbix && \
mkdir -p /var/lib/zabbix/modules && \
chown --quiet -R zabbix:root /var/lib/zabbix && \
yum ${YUM_FLAGS_COMMON} makecache && \
yum ${YUM_FLAGS_DEV} install epel-release && \
yum ${YUM_FLAGS_PERSISTANT} install \
libldap \
openssl-libs \
supervisor && \
openssl-libs && \
yum ${YUM_FLAGS_PERSISTANT} clean all && \
rm -rf /var/cache/yum/

Expand All @@ -48,7 +47,7 @@ ENV ZBX_VERSION=${ZBX_VERSION} ZBX_SOURCES=${ZBX_SOURCES}
LABEL org.label-schema.usage="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" \
org.label-schema.version="${ZBX_VERSION}" \
org.label-schema.vcs-url="${ZBX_SOURCES}" \
org.label-schema.docker.cmd="docker run --name zabbix-agent --link zabbix-server:zabbix-server -p 10050:10050 -d zabbix-agent:centos-${ZBX_VERSION}"
org.label-schema.docker.cmd="docker run --name zabbix-${ZBX_TYPE} --link zabbix-server:zabbix-server -p 10050:10050 -d zabbix-${ZBX_TYPE}:centos-${ZBX_VERSION}"

RUN yum --quiet makecache && \
yum ${YUM_FLAGS_DEV} install \
Expand Down Expand Up @@ -100,9 +99,6 @@ WORKDIR /var/lib/zabbix

VOLUME ["/etc/zabbix/zabbix_agentd.d", "/var/lib/zabbix/enc", "/var/lib/zabbix/modules"]

COPY ["conf/etc/supervisor/", "/etc/supervisor/"]
COPY ["docker-entrypoint.sh", "/usr/bin/"]

ENTRYPOINT ["docker-entrypoint.sh"]

CMD ["agentd", "none"]
5 changes: 5 additions & 0 deletions agent/centos/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ fi

if [ "$version" != "latest" ]; then
VCS_REF=`svn info svn://svn.zabbix.com/tags/$version |grep "Last Changed Rev"|awk '{print $4;}'`
else
MAJOR_VERSION=`cat Dockerfile | grep "ARG MAJOR_VERSION" | cut -f2 -d"="`
MINOR_VERSION=`cat Dockerfile | grep "ARG ZBX_VERSION" | cut -f2 -d"."`

VCS_REF=$MAJOR_VERSION.$MINOR_VERSION
fi

docker build -t zabbix-$app_component:$os-$version --build-arg VCS_REF="$VCS_REF" --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` -f Dockerfile .
Expand Down
17 changes: 0 additions & 17 deletions agent/centos/conf/etc/supervisor/conf.d/supervisord_zabbix.conf

This file was deleted.

35 changes: 0 additions & 35 deletions agent/centos/conf/etc/supervisor/supervisord.conf

This file was deleted.

46 changes: 38 additions & 8 deletions agent/centos/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ fi

# Type of Zabbix component
# Possible values: [server, proxy, agent, web, dev]
zbx_type="$1"
zbx_type=${ZBX_TYPE}
# Type of Zabbix database
# Possible values: [mysql, postgresql]
zbx_db_type="$2"
zbx_db_type=${ZBX_DB_TYPE}
# Type of web-server. Valid only with zbx_type = web
# Possible values: [apache, nginx]
zbx_opt_type="$3"
zbx_opt_type=${ZBX_OPT_TYPE}

# Default Zabbix installation name
# Used only by Zabbix web-interface
Expand Down Expand Up @@ -872,8 +872,8 @@ else
exit 1
fi

if [ -n "$zbx_db_type" ]; then
if [ -n "$zbx_opt_type" ]; then
if [ "$zbx_db_type" != "none" ]; then
if [ "$zbx_opt_type" != "none" ]; then
echo "** Deploying Zabbix $zbx_type ($zbx_opt_type) with $zbx_db_type database"
else
echo "** Deploying Zabbix $zbx_type with $zbx_db_type database"
Expand All @@ -894,7 +894,7 @@ prepare_system "$zbx_type" "$zbx_opt_type"
[ "$zbx_type" == "frontend" ] && prepare_web $zbx_opt_type $zbx_db_type
[ "${ZBX_ADD_WEB}" == "true" ] && prepare_web ${ZBX_WEB_SERVER} ${ZBX_MAIN_DB}

[ "$zbx_type" == "agentd" ] && prepare_agent
[ "$zbx_type" == "agent" ] && prepare_agent
[ "${ZBX_ADD_AGENT}" == "true" ] && prepare_agent

[ "$zbx_type" == "java-gateway" ] && prepare_java_gateway
Expand All @@ -904,7 +904,37 @@ clear_deploy "$zbx_type"

echo "########################################################"

echo "** Executing supervisord"
exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
if [ "$1" != "" ]; then
echo "** Executing '$@'"
exec "$@"
elif [ "$zbx_type" == "agent" ]; then
echo "** Starting Zabbix agent"
exec su zabbix -s "/bin/bash" -c "/usr/sbin/zabbix_agentd --foreground -c /etc/zabbix/zabbix_agentd.conf"
elif [ "$zbx_type" == "proxy" ]; then
echo "** Starting Zabbix proxy"
exec su zabbix -s "/bin/bash" -c "/usr/sbin/zabbix_proxy --foreground -c /etc/zabbix/zabbix_proxy.conf"
elif [ "$zbx_type" == "server" ]; then
echo "** Starting Zabbix server"
exec su zabbix -s "/bin/bash" -c "/usr/sbin/zabbix_server --foreground -c /etc/zabbix/zabbix_server.conf"
elif [ "$zbx_type" == "java-gateway" ]; then
echo "** Starting Zabbix Java Gateway"
exec su zabbix -s "/bin/bash" -c "/usr/sbin/zabbix_java_gateway"
elif [ "$zbx_type" == "frontend" ] && [ "$zbx_opt_type" == "apache" ]; then
echo "** Starting Zabbix frontend"
if [ -f "/usr/sbin/httpd" ]; then
exec /usr/sbin/httpd -D FOREGROUND
elif [ -f "/usr/sbin/apache2ctl" ]; then
exec source /etc/apache2/envvars && /usr/sbin/apache2ctl -D FOREGROUND
else
echo "Unknown Web-server. Exiting..."
exit 1
fi
elif [ -f "/usr/bin/supervisord" ]; then
echo "** Executing supervisord"
exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
else
echo "Unknown instructions. Exiting..."
exit 1
fi

#################################################
Loading

0 comments on commit 6a382c3

Please sign in to comment.