2018-09-18 11:39:26 -04:00
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
2021-08-30 16:53:13 -04:00
ARG JDK_VERSION = 8 -slim-buster
2021-01-31 11:35:39 -05:00
FROM openjdk:$JDK_VERSION as druidbase
2020-02-12 19:36:31 -05:00
2021-01-31 11:35:39 -05:00
# Bundle everything into one script so cleanup can reduce image size.
# Otherwise docker's layered images mean that things are not actually deleted.
COPY base-setup.sh /root/base-setup.sh
2021-04-24 11:27:07 -04:00
ARG KAFKA_VERSION
2021-05-25 15:49:49 -04:00
# ZooKeeper version to install in the base image
# This is passed in by maven at build time to align with the client version we depend on in the pom file
ARG ZK_VERSION
2021-03-11 12:07:51 -05:00
ARG APACHE_ARCHIVE_MIRROR_HOST = https://archive.apache.org
RUN APACHE_ARCHIVE_MIRROR_HOST = ${ APACHE_ARCHIVE_MIRROR_HOST } /root/base-setup.sh && rm -f /root/base-setup.sh
2021-01-31 11:35:39 -05:00
FROM druidbase
ARG MYSQL_VERSION
2021-07-08 15:25:37 -04:00
ARG MARIA_VERSION
ARG MYSQL_DRIVER_CLASSNAME = com.mysql.jdbc.Driver
2021-05-17 18:45:07 -04:00
ARG CONFLUENT_VERSION
2020-02-12 19:36:31 -05:00
# Verify Java version
RUN java -version
2014-11-06 13:23:24 -05:00
2019-01-15 11:33:31 -05:00
RUN echo "[mysqld]\ncharacter-set-server=utf8\ncollation-server=utf8_bin\n" >> /etc/mysql/my.cnf
2014-11-06 13:23:24 -05:00
# Setup metadata store
2018-02-07 14:19:25 -05:00
# touch is needed because OverlayFS's copy-up operation breaks POSIX standards. See https://github.com/docker/for-linux/issues/72.
RUN find /var/lib/mysql -type f -exec touch { } \; && /etc/init.d/mysql start \
2019-01-15 11:33:31 -05:00
&& echo "CREATE USER 'druid'@'%' IDENTIFIED BY 'diurd'; GRANT ALL ON druid.* TO 'druid'@'%'; CREATE database druid DEFAULT CHARACTER SET utf8mb4;" | mysql -u root \
2015-11-12 20:28:56 -05:00
&& /etc/init.d/mysql stop
2023-07-07 15:52:35 -04:00
# Add Druid scripts and jars
ADD bin/* /usr/local/druid/bin/
2015-11-12 20:28:56 -05:00
ADD lib/* /usr/local/druid/lib/
2022-01-06 02:33:04 -05:00
COPY extensions/ /usr/local/druid/extensions/
2014-11-06 13:23:24 -05:00
2018-10-20 21:18:58 -04:00
# Download the MySQL Java connector
2021-01-31 11:35:39 -05:00
# target path must match the exact path referenced in environment-configs/common
2021-07-08 15:25:37 -04:00
# alternatively: Download the MariaDB Java connector, and pretend it is the mysql connector
RUN if [ " $MYSQL_DRIVER_CLASSNAME " = "com.mysql.jdbc.Driver" ] ; \
then wget -q " https://repo1.maven.org/maven2/mysql/mysql-connector-java/ $MYSQL_VERSION /mysql-connector-java- $MYSQL_VERSION .jar " \
-O /usr/local/druid/lib/mysql-connector-java.jar; \
elif [ " $MYSQL_DRIVER_CLASSNAME " = "org.mariadb.jdbc.Driver" ] ; \
then wget -q " https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/ $MARIA_VERSION /mariadb-java-client- $MARIA_VERSION .jar " \
-O /usr/local/druid/lib/mysql-connector-java.jar; \
fi
# download kafka protobuf provider
2021-05-17 18:45:07 -04:00
RUN wget -q " https://packages.confluent.io/maven/io/confluent/kafka-protobuf-provider/ $CONFLUENT_VERSION /kafka-protobuf-provider- $CONFLUENT_VERSION .jar " \
-O /usr/local/druid/lib/kafka-protobuf-provider.jar
2014-11-06 13:23:24 -05:00
# Add sample data
2018-02-07 14:19:25 -05:00
# touch is needed because OverlayFS's copy-up operation breaks POSIX standards. See https://github.com/docker/for-linux/issues/72.
RUN find /var/lib/mysql -type f -exec touch { } \; && service mysql start \
2023-07-07 15:52:35 -04:00
&& /usr/local/druid/bin/run-java -cp "/usr/local/druid/lib/*" -Ddruid.extensions.directory= /usr/local/druid/extensions -Ddruid.extensions.loadList= '["mysql-metadata-storage"]' -Ddruid.metadata.storage.type= mysql -Ddruid.metadata.mysql.driver.driverClassName= $MYSQL_DRIVER_CLASSNAME org.apache.druid.cli.Main tools metadata-init --connectURI= "jdbc:mysql://localhost:3306/druid" --user= druid --password= diurd \
2015-11-12 20:28:56 -05:00
&& /etc/init.d/mysql stop
2020-03-17 06:08:44 -04:00
ADD test-data /test-data
2014-11-06 13:23:24 -05:00
# Setup supervisord
ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
2020-03-10 00:17:49 -04:00
# Add druid configuration setup script
ADD druid.sh /druid.sh
2018-09-19 12:56:15 -04:00
# mysql
ADD run-mysql.sh /run-mysql.sh
2018-02-07 16:06:06 -05:00
# internal docker_ip:9092 endpoint is used to access Kafka from other Docker containers
# external docker ip:9093 endpoint is used to access Kafka from test code
2015-11-12 20:28:56 -05:00
# run this last to avoid rebuilding the image every time the ip changes
ADD docker_ip docker_ip
2018-09-19 12:56:15 -04:00
RUN perl -pi -e "s/#listeners=.*/listeners=INTERNAL:\/\/172.172.172.2:9092,EXTERNAL:\/\/172.172.172.2:9093/" /usr/local/kafka/config/server.properties
RUN perl -pi -e " s/#advertised.listeners=.*/advertised.listeners=INTERNAL:\/\/172.172.172.2:9092,EXTERNAL:\/\/ $( cat docker_ip) :9093/ " /usr/local/kafka/config/server.properties
2018-02-07 16:06:06 -05:00
RUN perl -pi -e "s/#listener.security.protocol.map=.*/listener.security.protocol.map=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT\ninter.broker.listener.name=INTERNAL/" /usr/local/kafka/config/server.properties
RUN perl
2014-11-06 13:23:24 -05:00
2018-09-19 12:56:15 -04:00
# Add directory with TLS support files
ADD tls tls
ADD client_tls client_tls
2014-11-06 13:23:24 -05:00
# Expose ports:
2018-09-19 12:56:15 -04:00
# - 8081, 8281: HTTP, HTTPS (coordinator)
# - 8082, 8282: HTTP, HTTPS (broker)
# - 8083, 8283: HTTP, HTTPS (historical)
# - 8090, 8290: HTTP, HTTPS (overlord)
# - 8091, 8291: HTTP, HTTPS (middlemanager)
2018-10-24 19:31:52 -04:00
# - 8888-8891, 9088-9091: HTTP, HTTPS (routers)
2014-11-06 13:23:24 -05:00
# - 3306: MySQL
# - 2181 2888 3888: ZooKeeper
2018-09-19 12:56:15 -04:00
# - 8100 8101 8102 8103 8104 8105 : peon ports
# - 8300 8301 8302 8303 8304 8305 : peon HTTPS ports
EXPOSE 8081 8281
EXPOSE 8082 8282
EXPOSE 8083 8283
EXPOSE 8090 8290
EXPOSE 8091 8291
2014-11-06 13:23:24 -05:00
EXPOSE 3306
EXPOSE 2181 2888 3888
2018-09-19 12:56:15 -04:00
EXPOSE 8100 8101 8102 8103 8104 8105
EXPOSE 8300 8301 8302 8303 8304 8305
EXPOSE 9092 9093
2015-11-12 20:28:56 -05:00
2021-07-08 15:25:37 -04:00
ENV MYSQL_DRIVER_CLASSNAME = $MYSQL_DRIVER_CLASSNAME
2014-11-06 13:23:24 -05:00
WORKDIR /var/lib/druid
2021-07-08 15:25:37 -04:00
ENTRYPOINT /tls/generate-server-certs-and-keystores.sh \
2020-12-08 19:02:26 -05:00
&& . /druid.sh \
2020-03-10 00:17:49 -04:00
# Create druid service config files with all the config variables
2020-12-08 19:02:26 -05:00
&& setupConfig \
2020-03-17 06:08:44 -04:00
# Some test groups require pre-existing data to be setup
2020-12-08 19:02:26 -05:00
&& setupData \
2020-03-10 00:17:49 -04:00
# Export the service config file path to use in supervisord conf file
2021-08-13 16:40:25 -04:00
&& export DRUID_SERVICE_CONF_DIR = " $( . /druid.sh; getConfPath ${ DRUID_SERVICE } ) " \
2020-03-10 00:17:49 -04:00
# Export the common config file path to use in supervisord conf file
2021-08-13 16:40:25 -04:00
&& export DRUID_COMMON_CONF_DIR = " $( . /druid.sh; getConfPath _common) " \
2020-03-10 00:17:49 -04:00
# Run Druid service using supervisord
&& exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf