FROM ubuntu:18.04 LABEL maintainer="Amazon AI" #SDK 1.17.1 has version 1 LABEL dlc_major_version="2" # Specify accept-bind-to-port LABEL for inference pipelines to use SAGEMAKER_BIND_TO_PORT # https://docs.aws.amazon.com/sagemaker/latest/dg/inference-pipeline-real-time.html LABEL com.amazonaws.sagemaker.capabilities.accept-bind-to-port=true # Specify multi-models LABEL to indicate container is capable of loading and serving multiple models concurrently # https://docs.aws.amazon.com/sagemaker/latest/dg/build-multi-model-build-container.html LABEL com.amazonaws.sagemaker.capabilities.multi-models=true ARG MMS_VERSION=1.1.8 ARG PYTHON=python3 ARG PIP=pip3 ARG PYTHON_VERSION=3.7.10 ENV DEBIAN_FRONTEND=noninteractive ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib" \ PYTHONIOENCODING=UTF-8 \ LANG=C.UTF-8 \ LC_ALL=C.UTF-8 \ TEMP=/home/model-server/tmp RUN apt-get update \ && apt-get install -y --no-install-recommends \ build-essential \ ca-certificates \ curl \ emacs \ git \ libopencv-dev \ openjdk-8-jdk-headless \ openjdk-8-jdk \ openjdk-8-jre \ vim \ wget \ unzip \ zlib1g-dev \ libreadline-gplv2-dev \ libncursesw5-dev \ openssl \ libssl-dev \ libsqlite3-dev \ libgdbm-dev \ libc6-dev \ libbz2-dev \ tk-dev \ libffi-dev \ libcap-dev \ gnupg2 \ && apt-get clean \ && rm -rf /tmp/tmp* \ && rm -rf /var/lib/apt/lists/* ## This section is for allowing the automatic updates of vulnerable packages. COPY apt-upgrade-list.txt /tmp/apt-upgrade-list.txt RUN apt-get update \ && apt-get install --only-upgrade $(cat /tmp/apt-upgrade-list.txt) \ && rm -rf /tmp/apt-upgrade-list.txt RUN echo "deb https://apt.repos.neuron.amazonaws.com bionic main" > /etc/apt/sources.list.d/neuron.list RUN wget -qO - https://apt.repos.neuron.amazonaws.com/GPG-PUB-KEY-AMAZON-AWS-NEURON.PUB | apt-key add - RUN apt-get update \ && apt-get install -y \ aws-neuron-tools \ && rm -rf /var/lib/apt/lists/* \ && rm -rf /tmp/tmp* \ && apt-get clean # https://github.com/docker-library/openjdk/issues/261 https://github.com/docker-library/openjdk/pull/263/files RUN keytool -importkeystore -srckeystore /etc/ssl/certs/java/cacerts -destkeystore /etc/ssl/certs/java/cacerts.jks -deststoretype JKS -srcstorepass changeit -deststorepass changeit -noprompt; \ mv /etc/ssl/certs/java/cacerts.jks /etc/ssl/certs/java/cacerts; \ /var/lib/dpkg/info/ca-certificates-java.postinst configure; # install Python RUN wget -q https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz \ && tar -xzf Python-$PYTHON_VERSION.tgz \ && cd Python-$PYTHON_VERSION \ && ./configure --enable-shared --prefix=/usr/local \ && make -j $(nproc) && make install \ && cd .. && rm -rf ../Python-$PYTHON_VERSION* \ && ln -s /usr/local/bin/pip3 /usr/bin/pip \ && ln -s /usr/local/bin/$PYTHON /usr/local/bin/python \ && ${PIP} --no-cache-dir install --upgrade \ pip \ setuptools WORKDIR / RUN ${PIP} install --no-cache-dir \ "awscli<2" \ boto3 \ gluonnlp==0.10.0 \ gluoncv==0.8.0 \ multi-model-server==$MMS_VERSION \ keras-mxnet==2.2.4.1 \ numpy==1.17.4 \ onnx==1.7.0 \ sagemaker-mxnet-inference RUN ${PIP} install neuron-cc[tensorflow] --extra-index-url https://pip.repos.neuron.amazonaws.com \ && ${PIP} install --no-cache-dir -U \ https://aws-mx-pypi.s3.us-west-2.amazonaws.com/1.8.0/aws_mx-1.8.0.2-py2.py3-none-manylinux2014_x86_64.whl \ && ${PIP} install mx-neuron --extra-index-url https://pip.repos.neuron.amazonaws.com \ # Install TF 1.15.5 to override neuron-cc[tensorflow]'s installation of tensorflow==1.15.0 && pip install -U tensorflow==1.15.5 # This is here to make our installed version of OpenCV work. # https://stackoverflow.com/questions/29274638/opencv-libdc1394-error-failed-to-initialize-libdc1394 # TODO: Should we be installing OpenCV in our image like this? Is there another way we can fix this? RUN ln -s /dev/null /dev/raw1394 RUN useradd -m model-server \ && mkdir -p /home/model-server/tmp \ && chown -R model-server /home/model-server COPY neuron-entrypoint.py /usr/local/bin/dockerd-entrypoint.py COPY neuron-monitor.sh /usr/local/bin/neuron-monitor.sh COPY modelserver-neuron.sh /usr/local/bin/entrypoint.sh RUN chmod +x /usr/local/bin/dockerd-entrypoint.py \ && chmod +x /usr/local/bin/neuron-monitor.sh \ && chmod +x /usr/local/bin/entrypoint.sh COPY config.properties /home/model-server RUN HOME_DIR=/root \ && curl -o ${HOME_DIR}/oss_compliance.zip https://aws-dlinfra-utilities.s3.amazonaws.com/oss_compliance.zip \ && unzip ${HOME_DIR}/oss_compliance.zip -d ${HOME_DIR}/ \ && cp ${HOME_DIR}/oss_compliance/test/testOSSCompliance /usr/local/bin/testOSSCompliance \ && chmod +x /usr/local/bin/testOSSCompliance \ && chmod +x ${HOME_DIR}/oss_compliance/generate_oss_compliance.sh \ && ${HOME_DIR}/oss_compliance/generate_oss_compliance.sh ${HOME_DIR} ${PYTHON} \ && rm -rf ${HOME_DIR}/oss_compliance* RUN curl https://aws-dlc-licenses.s3.amazonaws.com/aws-mx-1.8.0/license.txt -o /license.txt EXPOSE 8080 8081 ENTRYPOINT ["python", "/usr/local/bin/dockerd-entrypoint.py"] CMD ["/usr/local/bin/entrypoint.sh"]