From e9e8d7bb1ab167a96dde29782290db14705f04e3 Mon Sep 17 00:00:00 2001 From: Roy Kim Date: Wed, 26 Aug 2020 09:59:03 +0900 Subject: [PATCH] [#74] docker for applying spring boot to pinpoint-collector --- .env | 21 +++++++------- docker-compose.yml | 13 ++++----- pinpoint-collector/.env | 28 +++++++++---------- pinpoint-collector/Dockerfile | 27 +++++++++--------- .../config/pinpoint-collector.properties | 8 ++++++ .../build/scripts/start-collector.sh | 12 +------- pinpoint-collector/docker-compose.yml | 18 ++++-------- 7 files changed, 57 insertions(+), 70 deletions(-) create mode 100644 pinpoint-collector/build/config/pinpoint-collector.properties diff --git a/.env b/.env index 21320c9..104c809 100644 --- a/.env +++ b/.env @@ -59,17 +59,18 @@ ALARM_MAIL_DEBUG=false ### Pinpoint-Collector -CLUSTER_ZOOKEEPER_ADDRESS=pinpoint-hbase - -HBASE_HOST=pinpoint-hbase -HBASE_PORT=2181 - PINPOINT_COLLECTOR_NAME=pinpoint-collector -COLLECTOR_RECEIVER_AGENT_PORT=9991 -COLLECTOR_RECEIVER_METADATA_PORT=9991 -COLLECTOR_RECEIVER_STAT_PORT=9992 -COLLECTOR_RECEIVER_SPAN_PORT=9993 +CLUSTER_ENABLE=true + +COLLECTOR_LOGGING_LEVEL_ROOT=INFO + +#grpc +COLLECTOR_RECEIVER_GRPC_AGENT_PORT=9991 +COLLECTOR_RECEIVER_GRPC_STAT_PORT=9992 +COLLECTOR_RECEIVER_GRPC_SPAN_PORT=9993 + +#thrift COLLECTOR_RECEIVER_BASE_PORT=9994 COLLECTOR_RECEIVER_STAT_UDP_PORT=9995 COLLECTOR_RECEIVER_SPAN_UDP_PORT=9996 @@ -77,8 +78,6 @@ COLLECTOR_RECEIVER_SPAN_UDP_PORT=9996 FLINK_CLUSTER_ENABLE=true FLINK_CLUSTER_ZOOKEEPER_ADDRESS=pinpoint-hbase -COLLECTOR_DEBUG_LEVEL=INFO - ### Pinpoint-Agent diff --git a/docker-compose.yml b/docker-compose.yml index 424004b..1ea9299 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -133,10 +133,9 @@ services: - "9995" - "9996" ports: - - "${COLLECTOR_RECEIVER_AGENT_PORT:-9991}:9991/udp" - - "${COLLECTOR_RECEIVER_METADATA_PORT:-9991}:9991/tcp" - - "${COLLECTOR_RECEIVER_STAT_PORT:-9992}:9992/tcp" - - "${COLLECTOR_RECEIVER_SPAN_PORT:-9993}:9993/tcp" + - "${COLLECTOR_RECEIVER_GRPC_AGENT_PORT:-9991}:9991/tcp" + - "${COLLECTOR_RECEIVER_GRPC_STAT_PORT:-9992}:9992/tcp" + - "${COLLECTOR_RECEIVER_GRPC_SPAN_PORT:-9993}:9993/tcp" - "${COLLECTOR_RECEIVER_BASE_PORT:-9994}:9994" - "${COLLECTOR_RECEIVER_STAT_UDP_PORT:-9995}:9995/tcp" - "${COLLECTOR_RECEIVER_SPAN_UDP_PORT:-9996}:9996/tcp" @@ -148,13 +147,11 @@ services: environment: - JAVA_OPTS="-Dspring.profiles.active=${SPRING_PROFILES}" - SPRING_PROFILES=${SPRING_PROFILES} + - PINPOINT_ZOOKEEPER_ADDRESS=${PINPOINT_ZOOKEEPER_ADDRESS} - CLUSTER_ENABLE=${CLUSTER_ENABLE} - - CLUSTER_ZOOKEEPER_ADDRESS=${CLUSTER_ZOOKEEPER_ADDRESS} - - HBASE_HOST=${HBASE_HOST} - - HBASE_PORT=${HBASE_PORT} + - LOGGING_LEVEL_ROOT=${COLLECTOR_LOGGING_LEVEL_ROOT} - FLINK_CLUSTER_ENABLE=${FLINK_CLUSTER_ENABLE} - FLINK_CLUSTER_ZOOKEEPER_ADDRESS=${FLINK_CLUSTER_ZOOKEEPER_ADDRESS} - - DEBUG_LEVEL=${COLLECTOR_DEBUG_LEVEL} pinpoint-quickstart: build: diff --git a/pinpoint-collector/.env b/pinpoint-collector/.env index 4b5abb4..e123f61 100644 --- a/pinpoint-collector/.env +++ b/pinpoint-collector/.env @@ -3,26 +3,26 @@ SPRING_PROFILES=release ### Pinpoint-Collector -CLUSTER_ENABLE=true -#zookeeper information required -CLUSTER_ZOOKEEPER_ADDRESS= - -#hbase information required -HBASE_HOST= -HBASE_PORT= - PINPOINT_COLLECTOR_NAME=pinpoint-collector -COLLECTOR_RECEIVER_AGENT_PORT=9991 -COLLECTOR_RECEIVER_METADATA_PORT=9991 -COLLECTOR_RECEIVER_STAT_PORT=9992 -COLLECTOR_RECEIVER_SPAN_PORT=9993 +#zookeeper information required +PINPOINT_ZOOKEEPER_ADDRESS= + +CLUSTER_ENABLE=true + +COLLECTOR_LOGGING_LEVEL_ROOT=INFO + +#grpc +COLLECTOR_RECEIVER_GRPC_AGENT_PORT=9991 +COLLECTOR_RECEIVER_GRPC_STAT_PORT=9992 +COLLECTOR_RECEIVER_GRPC_SPAN_PORT=9993 + +#thrift COLLECTOR_RECEIVER_BASE_PORT=9994 COLLECTOR_RECEIVER_STAT_UDP_PORT=9995 COLLECTOR_RECEIVER_SPAN_UDP_PORT=9996 FLINK_CLUSTER_ENABLE=true -FLINK_CLUSTER_ZOOKEEPER_ADDRESS=zoo1 +FLINK_CLUSTER_ZOOKEEPER_ADDRESS= -COLLECTOR_DEBUG_LEVEL=INFO diff --git a/pinpoint-collector/Dockerfile b/pinpoint-collector/Dockerfile index efc2a7f..445bd27 100644 --- a/pinpoint-collector/Dockerfile +++ b/pinpoint-collector/Dockerfile @@ -1,23 +1,22 @@ -FROM tomcat:8-jre8 +FROM openjdk:8-jdk-alpine LABEL maintainer="Roy Kim " ARG PINPOINT_VERSION=${PINPOINT_VERSION:-2.0.4} -ARG INSTALL_URL=https://github.com/naver/pinpoint/releases/download/v${PINPOINT_VERSION}/pinpoint-collector-${PINPOINT_VERSION}.war +ARG INSTALL_URL=https://github.com/naver/pinpoint/releases/download/v${PINPOINT_VERSION}/pinpoint-collector-boot-${PINPOINT_VERSION}.war -COPY /build/scripts/start-collector.sh /usr/local/bin/ +RUN mkdir -p /pinpoint/config \ + && mkdir -p /pinpoint/scripts -RUN chmod a+x /usr/local/bin/start-collector.sh \ - && curl -SL ${INSTALL_URL} -o pinpoint-collector.war \ - && rm -rf /usr/local/tomcat/webapps \ - && mkdir -p /usr/local/tomcat/webapps \ - && unzip pinpoint-collector.war -d /usr/local/tomcat/webapps/ROOT \ - && rm -rf pinpoint-collector.war \ - && sed -i "s/8005/9005/g" /usr/local/tomcat/conf/server.xml \ - && sed -i "s/8080/9080/g" /usr/local/tomcat/conf/server.xml \ - && sed -i "s/8009/9009/g" /usr/local/tomcat/conf/server.xml \ - && sed -i "s/8443/9443/g" /usr/local/tomcat/conf/server.xml +COPY /build/config/pinpoint-collector.properties /pinpoint/config/ +COPY /build/scripts/start-collector.sh /pinpoint/scripts/ +#temporary line for local test +#COPY /pinpoint-collector-boot-2.1.0-SNAPSHOT.jar /pinpoint/pinpoint-collector-boot.jar -ENTRYPOINT ["/usr/local/bin/start-collector.sh"] +RUN chmod a+x /pinpoint/scripts/start-collector.sh \ + && chmod a+x /pinpoint/config/pinpoint-collector.properties \ + && curl -SL ${INSTALL_URL} -o /pinpoint/pinpoint-collector-boot.jar + +ENTRYPOINT ["sh", "/pinpoint/scripts/start-collector.sh"] diff --git a/pinpoint-collector/build/config/pinpoint-collector.properties b/pinpoint-collector/build/config/pinpoint-collector.properties new file mode 100644 index 0000000..258c2ee --- /dev/null +++ b/pinpoint-collector/build/config/pinpoint-collector.properties @@ -0,0 +1,8 @@ +########## +# another way of setting properties. +# applied priority '.ENV' -> 'pinpoint-collector.properties' +# property should be commented in docker-compose file to use +# ex) PINPOINT_ZOOKEEPER_ADDRESS should be commented in docker-compose to use pinpoint.zookeeper.address below +########## +# +# pinpoint.zookeeper.address= \ No newline at end of file diff --git a/pinpoint-collector/build/scripts/start-collector.sh b/pinpoint-collector/build/scripts/start-collector.sh index 157ff58..724b7f3 100644 --- a/pinpoint-collector/build/scripts/start-collector.sh +++ b/pinpoint-collector/build/scripts/start-collector.sh @@ -2,14 +2,4 @@ set -e set -x -sed -i "/cluster.enable=/ s/=.*/=${CLUSTER_ENABLE}/" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/pinpoint-collector.properties -sed -i "/cluster.zookeeper.address=/ s/=.*/=${CLUSTER_ZOOKEEPER_ADDRESS}/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/pinpoint-collector.properties -sed -i "/flink.cluster.enable=/ s/=.*/=${FLINK_CLUSTER_ENABLE}/" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/pinpoint-collector.properties -sed -i "/flink.cluster.zookeeper.address=/ s/=.*/=${FLINK_CLUSTER_ZOOKEEPER_ADDRESS}/" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/pinpoint-collector.properties - -sed -i "/hbase.client.host=/ s/=.*/=${HBASE_HOST}/" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/profiles/${SPRING_PROFILES}/hbase-env.properties -sed -i "/hbase.client.port=/ s/=.*/=${HBASE_PORT}/" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/profiles/${SPRING_PROFILES}/hbase-env.properties - -sed -i "/level value=/ s/=.*/=\"${DEBUG_LEVEL}\"\/>/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/profiles/${SPRING_PROFILES}/log4j.xml - -exec /usr/local/tomcat/bin/catalina.sh run \ No newline at end of file +exec java -jar /pinpoint/pinpoint-collector-boot.jar --spring.config.additional-location=/pinpoint/config/pinpoint-web.properties \ No newline at end of file diff --git a/pinpoint-collector/docker-compose.yml b/pinpoint-collector/docker-compose.yml index 6f51036..a91a026 100644 --- a/pinpoint-collector/docker-compose.yml +++ b/pinpoint-collector/docker-compose.yml @@ -20,10 +20,9 @@ services: - "9995" - "9996" ports: - - "${COLLECTOR_RECEIVER_AGENT_PORT:-9991}:9991/udp" - - "${COLLECTOR_RECEIVER_METADATA_PORT:-9991}:9991/tcp" - - "${COLLECTOR_RECEIVER_STAT_PORT:-9992}:9992/tcp" - - "${COLLECTOR_RECEIVER_SPAN_PORT:-9993}:9993/tcp" + - "${COLLECTOR_RECEIVER_GRPC_AGENT_PORT:-9991}:9991/tcp" + - "${COLLECTOR_RECEIVER_GRPC_STAT_PORT:-9992}:9992/tcp" + - "${COLLECTOR_RECEIVER_GRPC_SPAN_PORT:-9993}:9993/tcp" - "${COLLECTOR_RECEIVER_BASE_PORT:-9994}:9994" - "${COLLECTOR_RECEIVER_STAT_UDP_PORT:-9995}:9995/tcp" - "${COLLECTOR_RECEIVER_SPAN_UDP_PORT:-9996}:9996/tcp" @@ -31,15 +30,10 @@ services: - "${COLLECTOR_RECEIVER_SPAN_UDP_PORT:-9996}:9996/udp" environment: + - JAVA_OPTS="-Dspring.profiles.active=${SPRING_PROFILES}" - SPRING_PROFILES=${SPRING_PROFILES} + - PINPOINT_ZOOKEEPER_ADDRESS=${PINPOINT_ZOOKEEPER_ADDRESS} - CLUSTER_ENABLE=${CLUSTER_ENABLE} - - CLUSTER_ZOOKEEPER_ADDRESS=${CLUSTER_ZOOKEEPER_ADDRESS} - - HBASE_HOST=${HBASE_HOST} - - HBASE_PORT=${HBASE_PORT} + - LOGGING_LEVEL_ROOT=${COLLECTOR_LOGGING_LEVEL_ROOT} - FLINK_CLUSTER_ENABLE=${FLINK_CLUSTER_ENABLE} - FLINK_CLUSTER_ZOOKEEPER_ADDRESS=${FLINK_CLUSTER_ZOOKEEPER_ADDRESS} - - DEBUG_LEVEL=${COLLECTOR_DEBUG_LEVEL} - -networks: - pinpoint: - driver: bridge