FROM ubuntu:16.04 LABEL maintainer="Amazon AI" LABEL com.amazonaws.sagemaker.capabilities.accept-bind-to-port=true ARG MMS_VERSION=1.1.6 ARG PYTHON=python3 ARG PYTHON_VERSION=3.6.8 ARG HEALTH_CHECK_VERSION=1.6.3 RUN apt-get update \ && apt-get -y install --no-install-recommends \ build-essential \ ca-certificates \ curl \ git \ libopencv-dev \ openjdk-8-jdk-headless \ vim \ wget \ zlib1g-dev \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # See http://bugs.python.org/issue19846 ENV LANG=C.UTF-8 \ PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib" \ PYTHONIOENCODING=UTF-8 \ LC_ALL=C.UTF-8 RUN wget https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz \ && tar -xvf Python-$PYTHON_VERSION.tgz \ && cd Python-$PYTHON_VERSION \ && ./configure \ && make \ && make install \ && apt-get update \ && apt-get install -y --no-install-recommends \ libreadline-gplv2-dev \ libncursesw5-dev \ libssl-dev \ libsqlite3-dev \ tk-dev \ libgdbm-dev \ libc6-dev \ libbz2-dev \ && make \ && make install \ && rm -rf ../Python-$PYTHON_VERSION* \ && ln -s /usr/local/bin/pip3 /usr/bin/pip \ && ln -s $(which ${PYTHON}) /usr/local/bin/python WORKDIR / RUN wget https://amazonei-tools.s3.amazonaws.com/v${HEALTH_CHECK_VERSION}/ei_tools_${HEALTH_CHECK_VERSION}.tar.gz -O /opt/ei_tools_${HEALTH_CHECK_VERSION}.tar.gz \ && tar -xvf /opt/ei_tools_${HEALTH_CHECK_VERSION}.tar.gz -C /opt/ \ && rm -rf /opt/ei_tools_${HEALTH_CHECK_VERSION}.tar.gz \ && chmod a+x /opt/ei_tools/bin/health_check RUN pip install --no-cache-dir --upgrade \ pip \ setuptools RUN pip install --no-cache-dir \ https://s3.amazonaws.com/amazonei-apachemxnet/amazonei_mxnet-1.5.1-py2.py3-none-manylinux1_x86_64.whl \ multi-model-server==$MMS_VERSION \ keras-mxnet==2.2.4.1 \ numpy==1.17.4 \ onnx==1.4.1 \ "sagemaker-mxnet-inference<2" # Install openssl-1.1.1g to override default openssl-1.0.2g RUN wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz \ && apt-get remove --purge -y openssl \ && rm -rf /usr/include/openssl \ && apt-get update \ && apt-get install -y \ ca-certificates \ openjdk-8-jdk-headless \ && tar -xzvf openssl-1.1.1g.tar.gz \ && cd openssl-1.1.1g \ && ./config \ && make \ && make test \ && make install \ && cd ../ \ && rm -rf openssl-* \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Purging default openssl in above command also prevents the new installation of openssl # from finding certificates at the pre-existing path. This env variable fixes the issue. ENV SSL_CERT_DIR=/etc/ssl/certs # 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 mms-entrypoint.py /usr/local/bin/dockerd-entrypoint.py COPY config.properties /home/model-server RUN chmod +x /usr/local/bin/dockerd-entrypoint.py EXPOSE 8080 8081 ENV TEMP=/home/model-server/tmp ENTRYPOINT ["python", "/usr/local/bin/dockerd-entrypoint.py"] CMD ["multi-model-server", "--start", "--mms-config", "/home/model-server/config.properties"]