|
| 1 | +# syntax=docker/dockerfile:1 |
| 2 | +# |
| 3 | +# Build context: project root (the Maven reactor needs every module). |
| 4 | +# |
| 5 | +FROM maven:3.9-eclipse-temurin-8 AS builder |
| 6 | + |
| 7 | +WORKDIR /workspace |
| 8 | + |
| 9 | +# Copy poms first to maximise dep-layer cache hits on rebuild. |
| 10 | +COPY pom.xml ./ |
| 11 | +COPY phoenix-ddb-utils/pom.xml phoenix-ddb-utils/pom.xml |
| 12 | +COPY phoenix-ddb-rest/pom.xml phoenix-ddb-rest/pom.xml |
| 13 | +COPY phoenix-ddb-assembly/pom.xml phoenix-ddb-assembly/pom.xml |
| 14 | +COPY coverage-report/pom.xml coverage-report/pom.xml |
| 15 | + |
| 16 | +# `|| true` because the cross-module reactor can't resolve siblings yet; |
| 17 | +# this step is only here to warm ~/.m2. |
| 18 | +RUN --mount=type=cache,target=/root/.m2 \ |
| 19 | + mvn -B -q -DskipTests \ |
| 20 | + -pl phoenix-ddb-utils,phoenix-ddb-rest,phoenix-ddb-assembly -am \ |
| 21 | + dependency:go-offline || true |
| 22 | + |
| 23 | +COPY phoenix-ddb-utils phoenix-ddb-utils |
| 24 | +COPY phoenix-ddb-rest phoenix-ddb-rest |
| 25 | +COPY phoenix-ddb-assembly phoenix-ddb-assembly |
| 26 | +COPY coverage-report coverage-report |
| 27 | +COPY bin bin |
| 28 | +COPY conf conf |
| 29 | +COPY README.md DDB_API_REFERENCE.md ./ |
| 30 | + |
| 31 | +RUN --mount=type=cache,target=/root/.m2 \ |
| 32 | + mvn -B -DskipTests \ |
| 33 | + -pl phoenix-ddb-assembly -am \ |
| 34 | + clean package |
| 35 | + |
| 36 | +RUN set -eux; \ |
| 37 | + # If the assembly module ever ships an additional *-bin.tar.gz (e.g. |
| 38 | + # with a classifier), fail loudly rather than silently picking one. |
| 39 | + count=$(find phoenix-ddb-assembly/target -maxdepth 1 -type f -name 'phoenix-adapters-*-bin.tar.gz' | wc -l); \ |
| 40 | + if [ "$count" -ne 1 ]; then \ |
| 41 | + echo "Expected exactly one phoenix-adapters-*-bin.tar.gz, found $count:" >&2; \ |
| 42 | + find phoenix-ddb-assembly/target -maxdepth 1 -type f -name 'phoenix-adapters-*-bin.tar.gz' >&2; \ |
| 43 | + exit 1; \ |
| 44 | + fi; \ |
| 45 | + tarball=$(find phoenix-ddb-assembly/target -maxdepth 1 -type f -name 'phoenix-adapters-*-bin.tar.gz'); \ |
| 46 | + cp "$tarball" /tmp/phoenix-adapters-bin.tar.gz |
| 47 | + |
| 48 | +FROM eclipse-temurin:8-jdk-jammy |
| 49 | + |
| 50 | +ENV JAVA_HOME=/opt/java/openjdk \ |
| 51 | + PHOENIX_ADAPTERS_HOME=/opt/phoenix-adapters \ |
| 52 | + PHOENIX_ADAPTERS_CONF_DIR=/opt/phoenix-adapters/conf \ |
| 53 | + PHOENIX_ADAPTERS_LOG_DIR=/var/log/phoenix-adapters \ |
| 54 | + PHOENIX_ADAPTERS_PID_DIR=/var/run/phoenix-adapters \ |
| 55 | + PHOENIX_REST_PORT=8842 \ |
| 56 | + ZOO_KEEPER_QUORUM=zookeeper:2181 \ |
| 57 | + HBASE_MASTER_HOST=hbase-master \ |
| 58 | + HBASE_MASTER_PORT=16000 |
| 59 | + |
| 60 | +RUN set -eux; \ |
| 61 | + apt-get update; \ |
| 62 | + apt-get install -y --no-install-recommends \ |
| 63 | + bash curl ca-certificates netcat-openbsd tini procps; \ |
| 64 | + rm -rf /var/lib/apt/lists/*; \ |
| 65 | + mkdir -p "${PHOENIX_ADAPTERS_LOG_DIR}" "${PHOENIX_ADAPTERS_PID_DIR}" |
| 66 | + |
| 67 | +COPY --from=builder /tmp/phoenix-adapters-bin.tar.gz /tmp/phoenix-adapters-bin.tar.gz |
| 68 | + |
| 69 | +RUN set -eux; \ |
| 70 | + mkdir -p "${PHOENIX_ADAPTERS_HOME}"; \ |
| 71 | + tar -xzf /tmp/phoenix-adapters-bin.tar.gz -C "${PHOENIX_ADAPTERS_HOME}" --strip-components=1; \ |
| 72 | + rm /tmp/phoenix-adapters-bin.tar.gz; \ |
| 73 | + chmod -R +x "${PHOENIX_ADAPTERS_HOME}/bin"; \ |
| 74 | + # The assembly ships a mix of hadoop-common 3.3.6 (declared in pom.xml) |
| 75 | + # and hadoop-hdfs/yarn/mapreduce 3.4.x (transitive from phoenix-core-client |
| 76 | + # via hbase-server:2.5.14-hadoop3). The 3.4.x jars register FileSystem |
| 77 | + # impls that reference `WithErasureCoding`, a class only present in |
| 78 | + # hadoop-common 3.4.x. When HBase returns a remote exception during |
| 79 | + # bootstrap, the client's classloader tries to enumerate FileSystem |
| 80 | + # impls, hits NoClassDefFoundError, and poisons the JVM. The REST |
| 81 | + # server only talks to HBase via RPC and never opens HDFS directly, |
| 82 | + # so we strip the 3.4.x hadoop client jars to break the cycle. |
| 83 | + rm -f "${PHOENIX_ADAPTERS_HOME}/lib/hadoop-hdfs-"*.jar \ |
| 84 | + "${PHOENIX_ADAPTERS_HOME}/lib/hadoop-hdfs-client-"*.jar \ |
| 85 | + "${PHOENIX_ADAPTERS_HOME}/lib/hadoop-yarn-"*.jar \ |
| 86 | + "${PHOENIX_ADAPTERS_HOME}/lib/hadoop-mapreduce-client-"*.jar \ |
| 87 | + "${PHOENIX_ADAPTERS_HOME}/lib/hadoop-distcp-"*.jar |
| 88 | + |
| 89 | +# Client-side WAL codec / RPC controller must match the server cluster. |
| 90 | +COPY docker/conf/phoenix-adapters/hbase-site.xml ${PHOENIX_ADAPTERS_CONF_DIR}/hbase-site.xml |
| 91 | + |
| 92 | +COPY docker/scripts/phoenix-adapters-entrypoint.sh /usr/local/bin/entrypoint.sh |
| 93 | +RUN chmod +x /usr/local/bin/entrypoint.sh |
| 94 | + |
| 95 | +EXPOSE 8842 |
| 96 | + |
| 97 | +ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/entrypoint.sh"] |
0 commit comments