|
| 1 | +FROM 137112412989.dkr.ecr.us-west-2.amazonaws.com/amazonlinux:2 |
| 2 | +ARG REGION |
| 3 | +ENV AWS_REGION ${REGION} |
| 4 | +RUN yum clean all |
| 5 | +RUN yum update -y |
| 6 | +RUN yum install -y awscli bigtop-utils curl gcc gzip unzip python3 python3-setuptools python3-pip python-devel python3-devel python-psutil gunzip tar wget liblapack* libblas* libopencv* libopenblas* |
| 7 | + |
| 8 | +# install nginx amazonlinux:2.0.20200304.0 does not have nginx, so need to install epel-release first |
| 9 | +RUN wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm |
| 10 | +RUN yum install -y epel-release-latest-7.noarch.rpm |
| 11 | +RUN yum install -y nginx |
| 12 | + |
| 13 | +RUN rm -rf /var/cache/yum |
| 14 | + |
| 15 | +ENV PYTHONDONTWRITEBYTECODE=1 |
| 16 | +ENV PYTHONUNBUFFERED=1 |
| 17 | +# http://blog.stuart.axelbrooke.com/python-3-on-spark-return-of-the-pythonhashseed |
| 18 | +ENV PYTHONHASHSEED 0 |
| 19 | +ENV PYTHONIOENCODING UTF-8 |
| 20 | +ENV PIP_DISABLE_PIP_VERSION_CHECK 1 |
| 21 | + |
| 22 | +# Install EMR Spark/Hadoop |
| 23 | +ENV HADOOP_HOME /usr/lib/hadoop |
| 24 | +ENV HADOOP_CONF_DIR /usr/lib/hadoop/etc/hadoop |
| 25 | +ENV SPARK_HOME /usr/lib/spark |
| 26 | + |
| 27 | +COPY yum/emr-apps.repo /etc/yum.repos.d/emr-apps.repo |
| 28 | + |
| 29 | +# Install hadoop / spark dependencies from EMR's yum repository for Spark optimizations. |
| 30 | +# replace placeholder with region in repository URL |
| 31 | +RUN sed -i "s/REGION/${AWS_REGION}/g" /etc/yum.repos.d/emr-apps.repo |
| 32 | +RUN adduser -N hadoop |
| 33 | + |
| 34 | +# These packages are a subset of what EMR installs in a cluster with the |
| 35 | +# "hadoop", "spark", and "hive" applications. |
| 36 | +# They include EMR-optimized libraries and extras. |
| 37 | +RUN yum install -y aws-hm-client \ |
| 38 | + aws-java-sdk \ |
| 39 | + aws-sagemaker-spark-sdk \ |
| 40 | + emr-goodies \ |
| 41 | + emr-ruby \ |
| 42 | + emr-scripts \ |
| 43 | + emr-s3-select \ |
| 44 | + emrfs \ |
| 45 | + hadoop \ |
| 46 | + hadoop-client \ |
| 47 | + hadoop-hdfs \ |
| 48 | + hadoop-hdfs-datanode \ |
| 49 | + hadoop-hdfs-namenode \ |
| 50 | + hadoop-httpfs \ |
| 51 | + hadoop-kms \ |
| 52 | + hadoop-lzo \ |
| 53 | + hadoop-yarn \ |
| 54 | + hadoop-yarn-nodemanager \ |
| 55 | + hadoop-yarn-proxyserver \ |
| 56 | + hadoop-yarn-resourcemanager \ |
| 57 | + hadoop-yarn-timelineserver \ |
| 58 | + hive \ |
| 59 | + hive-hcatalog \ |
| 60 | + hive-hcatalog-server \ |
| 61 | + hive-jdbc \ |
| 62 | + hive-server2 \ |
| 63 | + python37-numpy \ |
| 64 | + s3-dist-cp \ |
| 65 | + spark-core \ |
| 66 | + spark-datanucleus \ |
| 67 | + spark-external \ |
| 68 | + spark-history-server \ |
| 69 | + spark-python |
| 70 | + |
| 71 | + |
| 72 | +# Point Spark at proper python binary |
| 73 | +ENV PYSPARK_PYTHON=/usr/bin/python3 |
| 74 | + |
| 75 | +# Setup Spark/Yarn/HDFS user as root |
| 76 | +ENV PATH="/usr/bin:/opt/program:${PATH}" |
| 77 | +ENV YARN_RESOURCEMANAGER_USER="root" |
| 78 | +ENV YARN_NODEMANAGER_USER="root" |
| 79 | +ENV HDFS_NAMENODE_USER="root" |
| 80 | +ENV HDFS_DATANODE_USER="root" |
| 81 | +ENV HDFS_SECONDARYNAMENODE_USER="root" |
| 82 | + |
| 83 | +# Set up bootstrapping program and Spark configuration |
| 84 | +COPY *.whl /opt/program/ |
| 85 | +RUN /usr/bin/python3 -m pip install pipenv --upgrade |
| 86 | +COPY hadoop-config /opt/hadoop-config |
| 87 | +COPY nginx-config /opt/nginx-config |
| 88 | +COPY aws-config /opt/aws-config |
| 89 | +COPY Pipfile /opt/program/ |
| 90 | +COPY Pipfile.lock /opt/program/ |
| 91 | +COPY setup.py /opt/program/ |
| 92 | +ENV PIPENV_PIPFILE=/opt/program/Pipfile |
| 93 | +# Use --system flag, so it will install all packages into the system python, |
| 94 | +# and not into the virtualenv. Since docker containers do not need to have virtualenvs |
| 95 | +RUN pipenv install --system |
| 96 | +RUN /usr/bin/python3 -m pip install /opt/program/*.whl |
| 97 | + |
| 98 | +# Setup container bootstrapper |
| 99 | +COPY container-bootstrap-config /opt/container-bootstrap-config |
| 100 | +RUN chmod +x /opt/container-bootstrap-config/bootstrap.sh |
| 101 | +RUN /opt/container-bootstrap-config/bootstrap.sh |
| 102 | + |
| 103 | +# With this config, spark history server will not run as daemon, otherwise there |
| 104 | +# will be no server running and container will terminate immediately |
| 105 | +ENV SPARK_NO_DAEMONIZE TRUE |
| 106 | + |
| 107 | +WORKDIR $SPARK_HOME |
| 108 | + |
| 109 | +ENTRYPOINT ["smspark-submit"] |
0 commit comments