Skip to content

Commit

Permalink
fix entrypoint.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
mimuret committed Aug 24, 2019
1 parent ebe2fa3 commit b458144
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2
jobs:
deploy:
build:
environment:
GOPATH: /home/circleci/go
CGO_ENABLED: 0
Expand Down Expand Up @@ -33,7 +33,7 @@ workflows:
- test
deploy:
jobs:
- deploy:
- build:
filters:
branches:
ignore: /.*/
Expand Down
40 changes: 35 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
FROM golang:1.12 as builder
FROM golang:1.12-alpine3.10 as builder
COPY . /build
RUN cd /build/cmd/dtap && go build
RUN apk --update --no-cache add git gcc musl-dev \
&& cd /build/cmd/dtap \
&& go build

FROM alpine:latest
FROM alpine:3.10

ENV DTAP_INPUT_UNIX_SOCKET "/dtap/dnstap.sock"
ENV DTAP_INPUT_UNIX_SOCKET_USER "daemon"
ENV DTAP_INPUT_TCP_LISTEN_ADDR ""
ENV DTAP_INPUT_TCP_LISTEN_PORT "10053"
ENV DTAP_OUTPUT_TCP_HOST ""
ENV DTAP_OUTPUT_TCP_PORT "10053"
ENV DTAP_OUTPUT_UNIX_SOCKET ""
ENV DTAP_OUTPUT_FLUENT_HOSTS ""
ENV DTAP_OUTPUT_FLUENT_PORT "24224"
ENV DTAP_OUTPUT_FLUENT_TAG "dnstap"
ENV DTAP_OUTPUT_KAFKA_HOSTS ""
ENV DTAP_OUTPUT_KAFKA_TOPIC "dnstap_message"
ENV DTAP_OUTPUT_NATS_HOST ""
ENV DTAP_OUTPUT_NATS_SUBJECT "dnstap_message"
ENV DTAP_OUTPUT_NATS_USER ""
ENV DTAP_OUTPUT_NATS_PASS ""
ENV DTAP_OUTPUT_NATS_TOKEN ""
ENV DTAP_IPV4_MASK 24
ENV DTAP_IPV6_MASK 48
ENV DTAP_ENABLE_ECS "false"
ENV DTAP_ENABLE_HASH_IP "false"
ENV DTAP_ENABLE_HASH_SALT ""

COPY entrypoint.sh /
COPY --from=builder /build/cmd/dtap/dtap /usr/bin/dtap
COPY misc/dtap.toml /config.toml

CMD ["/usr/bin/dtap"]
RUN mkdir /etc/dtap \
&& chmod 755 /entrypoint.sh

ENTRYPOINT [ "/entrypoint.sh" ]
CMD ["/usr/bin/dtap", "-c", "/etc/dtap/dtap.conf"]
80 changes: 80 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/ash

if [ ! -e "/etc/dtap/dtap.conf" ] ; then
if [ "${DTAP_INPUT_UNIX_SOCKET}" != "" ] ; then
cat <<- EOS >> /etc/dtap/dtap.conf
[[InputUnix]]
Path="${DTAP_INPUT_UNIX_SOCKET}"
User="${DTAP_INPUT_UNIX_SOCKET_USER}"
EOS
fi
if [ "${DTAP_INPUT_TCP_LISTEN_ADDR}" != "" ] ; then
cat <<- EOS >> /etc/dtap/dtap.conf
[[InputTCP]]
Address="${DTAP_INPUT_TCP_LISTEN_ADDR}"
Port=${DTAP_INPUT_TCP_LISTEN_PORT}
EOS
fi
if [ "${DTAP_OUTPUT_TCP_HOST}" != "" ] ; then
cat <<- EOS >> /etc/dtap/dtap.conf
[[OutputTCP]]
Host="${DTAP_OUTPUT_TCP_HOST}"
Port=${DTAP_OUTPUT_TCP_PORT}
EOS
fi
if [ "$DTAP_OUTPUT_UNIX_SOCKET" != "" ] ; then
cat <<- EOS >> /etc/dtap/dtap.conf
[[OutputUnix]]
Path="${DTAP_OUTPUT_UNIX_SOCKET}"
EOS
fi
if [ "${DTAP_OUTPUT_FLUENT_HOST}"] ; then
cat <<- EOS >> /etc/dtap/dtap.conf
[[OutputFluent]]
Host = "${DTAP_OUTPUT_FLUENT_HOST}"
Port = ${DTAP_OUTPUT_FLUENT_PORT}
Tag = "${DTAP_OUTPUT_FLUENT_TAG}"
[OutputKafka.flat]
IPv4Mask = ${DTAP_IPV4_MASK}
IPv6Mask = ${DTAP_IPV6_MASK}
EnableECS = ${DTAP_ENABLE_ECS}
EnableHashIP = ${DTAP_ENABLE_HASH_IP}
IPHashSaltPath = "${DTAP_ENABLE_HASH_SALT}"
EOS

fi
if [ "${DTAP_OUTPUT_KAFKA_HOSTS}" != "" ] ; then
host=$(echo ${DTAP_OUTPUT_KAFKA_HOSTS} | sed 's/,/","/g')
cat <<- EOS >> /etc/dtap/dtap.conf
[[OutputKafka]]
Hosts = ["${host}"]
Topic = "${DTAP_OUTPUT_KAFKA_TOPIC}"
[OutputKafka.flat]
IPv4Mask = ${DTAP_IPV4_MASK}
IPv6Mask = ${DTAP_IPV6_MASK}
EnableECS = ${DTAP_ENABLE_ECS}
EnableHashIP = ${DTAP_ENABLE_HASH_IP}
IPHashSaltPath = "${DTAP_ENABLE_HASH_SALT}"
EOS
fi
if [ "${DTAP_OUTPUT_NATS_HOST}" != "" ] ; then
cat <<- EOS >> /etc/dtap/dtap.conf
[[OutputNats]]
Hosts = "${DTAP_OUTPUT_NATS_HOST}"
User = "${DTAP_OUTPUT_NATS_USER}"
Password = "${DTAP_OUTPUT_NATS_PASS}"
Token = "${DTAP_OUTPUT_NATS_TOKEN}"
Subject = "${DTAP_OUTPUT_NATS_SUBJECT}"
[OutputNats.flat]
IPv4Mask = ${DTAP_IPV4_MASK}
IPv6Mask = ${DTAP_IPV6_MASK}
EnableECS = ${DTAP_ENABLE_ECS}
EnableHashIP = ${DTAP_ENABLE_HASH_IP}
IPHashSaltPath = "${DTAP_ENABLE_HASH_SALT}"
EOS
fi
fi

cat /etc/dtap/dtap.conf

exec "$@"

0 comments on commit b458144

Please sign in to comment.