Skip to content

Commit

Permalink
Refactor alpine dockerfile and unify entrypoints
Browse files Browse the repository at this point in the history
  • Loading branch information
aerostitch committed Aug 10, 2017
1 parent 8f066cf commit 2c3a26c
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 385 deletions.
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ MAINTAINER Datadog <[email protected]>

ENV DOCKER_DD_AGENT=yes \
AGENT_VERSION=1:5.16.0-1 \
DD_ETC_ROOT=/etc/dd-agent \
PATH="/opt/datadog-agent/embedded/bin:/opt/datadog-agent/bin:${PATH}" \
PYTHONPATH=/opt/datadog-agent/agent \
DD_CONF_LOG_TO_SYSLOG=no \
Expand All @@ -22,13 +23,13 @@ RUN echo "deb http://apt.datadoghq.com/ stable main" > /etc/apt/sources.list.d/d
# Configure the Agent
# 1. Remove dd-agent user from init.d configuration
# 2. Fix permission on /etc/init.d/datadog-agent
RUN mv /etc/dd-agent/datadog.conf.example /etc/dd-agent/datadog.conf \
RUN mv ${DD_ETC_ROOT}/datadog.conf.example ${DD_ETC_ROOT}/datadog.conf \
&& sed -i 's/AGENTUSER="dd-agent"/AGENTUSER="root"/g' /etc/init.d/datadog-agent \
&& rm -f /etc/dd-agent/conf.d/network.yaml.default \
&& rm -f ${DD_ETC_ROOT}/conf.d/network.yaml.default \
&& chmod +x /etc/init.d/datadog-agent

# Add Docker check
COPY conf.d/docker_daemon.yaml /etc/dd-agent/conf.d/docker_daemon.yaml
COPY conf.d/docker_daemon.yaml ${DD_ETC_ROOT}/conf.d/docker_daemon.yaml
# Add install and config files
COPY entrypoint.sh /entrypoint.sh
COPY config_builder.py /config_builder.py
Expand Down
55 changes: 27 additions & 28 deletions alpine/Dockerfile → Dockerfile-alpine
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,49 @@ ENV DD_HOME=/opt/datadog-agent \
DD_START_AGENT=0 \
DOCKER_DD_AGENT=yes \
PYCURL_SSL_LIBRARY=openssl \
AGENT_VERSION=5.16.0

# Add Docker check
COPY conf.d/docker_daemon.yaml "$DD_HOME/agent/conf.d/docker_daemon.yaml"

# Add install and config files
ADD https://raw.githubusercontent.com/DataDog/dd-agent/master/packaging/datadog-agent/source/setup_agent.sh /tmp/setup_agent.sh
COPY entrypoint.sh /entrypoint.sh

# Expose supervisor and DogStatsD port
EXPOSE 9001/tcp 8125/udp
AGENT_VERSION=5.16.0 \
DD_ETC_ROOT="/opt/datadog-agent/agent" \
PATH="/opt/datadog-agent/agent/embedded/bin:/opt/datadog-agent/agent/bin:$PATH" \
PYTHONPATH="/opt/datadog-agent/agent" \
DD_CONF_LOG_TO_SYSLOG=no \
NON_LOCAL_TRAFFIC=yes \
DD_SUPERVISOR_DELETE_USER=yes

# Install minimal dependencies
RUN apk add -qU --no-cache coreutils curl curl-dev python-dev tar sysstat tini

# Install build dependencies
ADD https://raw.githubusercontent.com/DataDog/dd-agent/master/packaging/datadog-agent/source/setup_agent.sh /tmp/setup_agent.sh
RUN apk add -qU --no-cache -t .build-deps gcc musl-dev pgcluster-dev linux-headers \
# Install the agent
&& sh /tmp/setup_agent.sh \
# Clean build dependencies
&& apk del -q .build-deps
&& apk del -q .build-deps \
&& rm /tmp/setup_agent.sh

# Configure the Agent
# 1. Listen to statsd from other containers
# 2. Turn syslog off
# 3. Remove dd-agent user from supervisor configuration
# 4. Remove setup script
RUN cp "$DD_HOME/agent/datadog.conf.example" "$DD_HOME/agent/datadog.conf" \
&& sed -i -e"s/^.*non_local_traffic:.*$/non_local_traffic: yes/" "$DD_HOME/agent/datadog.conf" \
&& sed -i -e"s/^.*log_to_syslog:.*$/log_to_syslog: no/" "$DD_HOME/agent/datadog.conf" \
&& sed -i "/user=dd-agent/d" "$DD_HOME/agent/supervisor.conf" \
&& rm "$DD_HOME/agent/conf.d/network.yaml.default" \
|| rm /tmp/setup_agent.sh
RUN cp ${DD_ETC_ROOT}/datadog.conf.example ${DD_ETC_ROOT}/datadog.conf \
&& rm -f ${DD_ETC_ROOT}/conf.d/network.yaml.default

# Add Docker check
COPY conf.d/docker_daemon.yaml "${DD_ETC_ROOT}/conf.d/docker_daemon.yaml"
# Add install and config files
COPY entrypoint.sh /entrypoint.sh
COPY config_builder.py /config_builder.py

# Extra conf.d and checks.d
VOLUME ["/conf.d", "/checks.d"]

# Expose supervisor and DogStatsD port
EXPOSE 9001/tcp 8125/udp

# Healthcheck
HEALTHCHECK --interval=5m --timeout=3s --retries=1 \
CMD test $($DD_HOME/venv/bin/python $DD_HOME/venv/bin/supervisorctl \
-c $DD_HOME/agent/supervisor.conf status | awk '{print $2}' | egrep -v 'RUNNING|EXITED' | wc -l) \
-c ${DD_ETC_ROOT}/supervisor.conf status | awk '{print $2}' | egrep -v 'RUNNING|EXITED' | wc -l) \
-eq 0 || exit 1

# Extra conf.d and checks.d
VOLUME ["/conf.d", "/checks.d"]

ENTRYPOINT ["/sbin/tini", "-g", "--", "/entrypoint.sh"]

WORKDIR "$DD_HOME"
CMD source venv/bin/activate && supervisord -c agent/supervisor.conf
WORKDIR $DD_HOME
CMD ["supervisord", "-c", "agent/supervisor.conf"]
126 changes: 0 additions & 126 deletions alpine/conf.d/docker_daemon.yaml

This file was deleted.

Loading

0 comments on commit 2c3a26c

Please sign in to comment.