|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 2 | +# contributor license agreements. See the NOTICE file distributed with |
| 3 | +# this work for additional information regarding copyright ownership. |
| 4 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 5 | +# (the "License"); you may not use this file except in compliance with |
| 6 | +# the License. You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# |
| 16 | +# syntax=docker/dockerfile:1 |
| 17 | +FROM python:3.10-bullseye |
| 18 | + |
| 19 | +RUN apt-get update && \ |
| 20 | + apt-get install -y --no-install-recommends \ |
| 21 | + sudo \ |
| 22 | + curl \ |
| 23 | + vim \ |
| 24 | + unzip \ |
| 25 | + openjdk-17-jdk \ |
| 26 | + build-essential \ |
| 27 | + software-properties-common \ |
| 28 | + ssh && \ |
| 29 | + apt-get clean && \ |
| 30 | + rm -rf /var/lib/apt/lists/* |
| 31 | + |
| 32 | +# Install Jupyter and other python deps |
| 33 | +COPY requirements.txt . |
| 34 | +RUN pip3 install -r requirements.txt |
| 35 | + |
| 36 | +# Add scala kernel via spylon-kernel |
| 37 | +RUN python3 -m spylon_kernel install |
| 38 | + |
| 39 | +# Download and install IJava jupyter kernel |
| 40 | +RUN curl https://github.com/SpencerPark/IJava/releases/download/v1.3.0/ijava-1.3.0.zip -Lo ijava-1.3.0.zip \ |
| 41 | + && unzip ijava-1.3.0.zip \ |
| 42 | + && python3 install.py --sys-prefix \ |
| 43 | + && rm ijava-1.3.0.zip |
| 44 | + |
| 45 | +# Optional env variables |
| 46 | +ENV SPARK_HOME=${SPARK_HOME:-"/opt/spark"} |
| 47 | +ENV PYTHONPATH=$SPARK_HOME/python:$SPARK_HOME/python/lib/py4j-0.10.9.7-src.zip:$PYTHONPATH |
| 48 | + |
| 49 | +WORKDIR ${SPARK_HOME} |
| 50 | + |
| 51 | +ENV SPARK_VERSION=3.5.5 |
| 52 | +ENV SPARK_MAJOR_VERSION=3.5 |
| 53 | +ENV ICEBERG_VERSION=1.8.1 |
| 54 | + |
| 55 | +# Download spark |
| 56 | +RUN mkdir -p ${SPARK_HOME} \ |
| 57 | + && curl https://dlcdn.apache.org/spark/spark-${SPARK_VERSION}/spark-${SPARK_VERSION}-bin-hadoop3.tgz -o spark-${SPARK_VERSION}-bin-hadoop3.tgz \ |
| 58 | + && tar xvzf spark-${SPARK_VERSION}-bin-hadoop3.tgz --directory /opt/spark --strip-components 1 \ |
| 59 | + && rm -rf spark-${SPARK_VERSION}-bin-hadoop3.tgz |
| 60 | + |
| 61 | +# Download iceberg spark runtime |
| 62 | +RUN curl https://repo1.maven.org/maven2/org/apache/iceberg/iceberg-spark-runtime-${SPARK_MAJOR_VERSION}_2.12/${ICEBERG_VERSION}/iceberg-spark-runtime-${SPARK_MAJOR_VERSION}_2.12-${ICEBERG_VERSION}.jar -Lo /opt/spark/jars/iceberg-spark-runtime-${SPARK_MAJOR_VERSION}_2.12-${ICEBERG_VERSION}.jar |
| 63 | + |
| 64 | +# Download AWS bundle |
| 65 | +RUN curl -s https://repo1.maven.org/maven2/org/apache/iceberg/iceberg-aws-bundle/${ICEBERG_VERSION}/iceberg-aws-bundle-${ICEBERG_VERSION}.jar -Lo /opt/spark/jars/iceberg-aws-bundle-${ICEBERG_VERSION}.jar |
| 66 | + |
| 67 | +# Download GCP bundle |
| 68 | +RUN curl -s https://repo1.maven.org/maven2/org/apache/iceberg/iceberg-gcp-bundle/${ICEBERG_VERSION}/iceberg-gcp-bundle-${ICEBERG_VERSION}.jar -Lo /opt/spark/jars/iceberg-gcp-bundle-${ICEBERG_VERSION}.jar |
| 69 | + |
| 70 | +# Download Azure bundle |
| 71 | +RUN curl -s https://repo1.maven.org/maven2/org/apache/iceberg/iceberg-azure-bundle/${ICEBERG_VERSION}/iceberg-azure-bundle-${ICEBERG_VERSION}.jar -Lo /opt/spark/jars/iceberg-azure-bundle-${ICEBERG_VERSION}.jar |
| 72 | + |
| 73 | +# Install AWS CLI |
| 74 | +RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \ |
| 75 | + && unzip awscliv2.zip \ |
| 76 | + && sudo ./aws/install \ |
| 77 | + && rm awscliv2.zip \ |
| 78 | + && rm -rf aws/ |
| 79 | + |
| 80 | +# Add iceberg spark runtime jar to IJava classpath |
| 81 | +ENV IJAVA_CLASSPATH=/opt/spark/jars/* |
| 82 | + |
| 83 | +RUN mkdir -p /home/iceberg/data \ |
| 84 | + && curl https://data.cityofnewyork.us/resource/tg4x-b46p.json > /home/iceberg/data/nyc_film_permits.json \ |
| 85 | + && curl https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2022-04.parquet -o /home/iceberg/data/yellow_tripdata_2022-04.parquet \ |
| 86 | + && curl https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2022-03.parquet -o /home/iceberg/data/yellow_tripdata_2022-03.parquet \ |
| 87 | + && curl https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2022-02.parquet -o /home/iceberg/data/yellow_tripdata_2022-02.parquet \ |
| 88 | + && curl https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2022-01.parquet -o /home/iceberg/data/yellow_tripdata_2022-01.parquet \ |
| 89 | + && curl https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2021-12.parquet -o /home/iceberg/data/yellow_tripdata_2021-12.parquet \ |
| 90 | + && curl https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2021-11.parquet -o /home/iceberg/data/yellow_tripdata_2021-11.parquet \ |
| 91 | + && curl https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2021-10.parquet -o /home/iceberg/data/yellow_tripdata_2021-10.parquet \ |
| 92 | + && curl https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2021-09.parquet -o /home/iceberg/data/yellow_tripdata_2021-09.parquet \ |
| 93 | + && curl https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2021-08.parquet -o /home/iceberg/data/yellow_tripdata_2021-08.parquet \ |
| 94 | + && curl https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2021-07.parquet -o /home/iceberg/data/yellow_tripdata_2021-07.parquet \ |
| 95 | + && curl https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2021-06.parquet -o /home/iceberg/data/yellow_tripdata_2021-06.parquet \ |
| 96 | + && curl https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2021-05.parquet -o /home/iceberg/data/yellow_tripdata_2021-05.parquet \ |
| 97 | + && curl https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2021-04.parquet -o /home/iceberg/data/yellow_tripdata_2021-04.parquet |
| 98 | + |
| 99 | +RUN mkdir -p /home/iceberg/localwarehouse /home/iceberg/notebooks /home/iceberg/warehouse /home/iceberg/spark-events /home/iceberg |
| 100 | +COPY notebooks/ /home/iceberg/notebooks |
| 101 | + |
| 102 | +# Add a notebook command |
| 103 | +RUN echo '#! /bin/sh' >> /bin/notebook \ |
| 104 | + && echo 'export PYSPARK_DRIVER_PYTHON=jupyter-notebook' >> /bin/notebook \ |
| 105 | + && echo "export PYSPARK_DRIVER_PYTHON_OPTS=\"--notebook-dir=/home/iceberg/notebooks --ip='*' --NotebookApp.token='' --NotebookApp.password='' --port=8888 --no-browser --allow-root\"" >> /bin/notebook \ |
| 106 | + && echo "pyspark" >> /bin/notebook \ |
| 107 | + && chmod u+x /bin/notebook |
| 108 | + |
| 109 | +# Add a pyspark-notebook command (alias for notebook command for backwards-compatibility) |
| 110 | +RUN echo '#! /bin/sh' >> /bin/pyspark-notebook \ |
| 111 | + && echo 'export PYSPARK_DRIVER_PYTHON=jupyter-notebook' >> /bin/pyspark-notebook \ |
| 112 | + && echo "export PYSPARK_DRIVER_PYTHON_OPTS=\"--notebook-dir=/home/iceberg/notebooks --ip='*' --NotebookApp.token='' --NotebookApp.password='' --port=8888 --no-browser --allow-root\"" >> /bin/pyspark-notebook \ |
| 113 | + && echo "pyspark" >> /bin/pyspark-notebook \ |
| 114 | + && chmod u+x /bin/pyspark-notebook |
| 115 | + |
| 116 | +RUN mkdir -p /root/.ipython/profile_default/startup |
| 117 | +COPY ipython/startup/00-prettytables.py /root/.ipython/profile_default/startup |
| 118 | +COPY ipython/startup/README /root/.ipython/profile_default/startup |
| 119 | + |
| 120 | +COPY spark-defaults.conf /opt/spark/conf |
| 121 | +ENV PATH="/opt/spark/sbin:/opt/spark/bin:${PATH}" |
| 122 | + |
| 123 | +RUN chmod u+x /opt/spark/sbin/* && \ |
| 124 | + chmod u+x /opt/spark/bin/* |
| 125 | + |
| 126 | +COPY .pyiceberg.yaml /root/.pyiceberg.yaml |
| 127 | + |
| 128 | +COPY entrypoint.sh . |
| 129 | + |
| 130 | +ENTRYPOINT ["./entrypoint.sh"] |
| 131 | +CMD ["notebook"] |
0 commit comments