|
| 1 | +# ============================================================ |
| 2 | +# Build stage 1: Builder |
| 3 | +# ============================================================ |
| 4 | + |
| 5 | +FROM maven:3.6-jdk-11 as builder |
| 6 | + |
| 7 | +ARG SPARK_VERSION=2.4.5 |
| 8 | +ARG HADOOP_VERSION=2.7 |
| 9 | + |
| 10 | +# Install Spark runtime |
| 11 | +WORKDIR / |
| 12 | + |
| 13 | +RUN wget -q https://archive.apache.org/dist/spark/spark-${SPARK_VERSION}/spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}.tgz \ |
| 14 | + && tar -zxf spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}.tgz \ |
| 15 | + && mv spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION} spark |
| 16 | + |
| 17 | +RUN cd spark/jars && for jar in \ |
| 18 | + org/apache/spark/spark-sql-kafka-0-10_2.11/2.4.5/spark-sql-kafka-0-10_2.11-2.4.5.jar \ |
| 19 | + org/apache/kafka/kafka-clients/2.3.0/kafka-clients-2.3.0.jar \ |
| 20 | + ; do \ |
| 21 | + wget https://repo1.maven.org/maven2/$jar; \ |
| 22 | + done |
| 23 | + |
| 24 | +RUN mv spark/conf/log4j.properties.template spark/conf/log4j.properties |
| 25 | + |
| 26 | +ARG REVISION=dev |
| 27 | + |
| 28 | +WORKDIR /build |
| 29 | + |
| 30 | +COPY datatypes datatypes |
| 31 | +COPY storage storage |
| 32 | +COPY sdk/java sdk/java |
| 33 | +COPY core core |
| 34 | +COPY ingestion ingestion |
| 35 | +COPY protos protos |
| 36 | +COPY serving serving |
| 37 | +COPY spark spark |
| 38 | +COPY pom.xml pom.xml |
| 39 | + |
| 40 | +# Trick to copy .m2 directory only if it exists. |
| 41 | +# The LICENSE file is any file that actually exists, to make sure the command doesn't fail. |
| 42 | +COPY LICENSE .m[2] .m2/ |
| 43 | + |
| 44 | +# |
| 45 | +# Setting Maven repository .m2 directory relative to /build folder gives the |
| 46 | +# user to optionally use cached repository when building the image by copying |
| 47 | +# the existing .m2 directory to $FEAST_REPO_ROOT/.m2 |
| 48 | +# |
| 49 | +ENV MAVEN_OPTS="-Dmaven.repo.local=/build/.m2/repository -DdependencyLocationsEnabled=false" |
| 50 | +RUN mvn --also-make --projects spark/databricks-emulator -Drevision=$REVISION \ |
| 51 | + --batch-mode clean package |
| 52 | + |
| 53 | +# ============================================================ |
| 54 | +# Build stage 2: Production |
| 55 | +# ============================================================ |
| 56 | + |
| 57 | +FROM openjdk:8u252-jre as production |
| 58 | +ARG REVISION=dev |
| 59 | + |
| 60 | +ENV SPARK_HOME /spark |
| 61 | + |
| 62 | +COPY --from=builder /spark /spark |
| 63 | +COPY --from=builder /build/spark/databricks-emulator/target/databricks-emulator-$REVISION.jar /opt/databricks-emulator.jar |
| 64 | +CMD ["java",\ |
| 65 | + "-Xms2048m",\ |
| 66 | + "-Xmx2048m",\ |
| 67 | + "-jar",\ |
| 68 | + "/opt/databricks-emulator.jar"] |
0 commit comments