FROM ubuntu:18.04 # Set a docker label to advertise multi-model support on the container LABEL com.amazonaws.sagemaker.capabilities.multi-models=true # Set a docker label to enable container to use SAGEMAKER_BIND_TO_PORT environment variable if present LABEL com.amazonaws.sagemaker.capabilities.accept-bind-to-port=true RUN apt-get update && apt-get install -y \ python3.7 \ python3-pip RUN python3.7 -m pip install pip RUN apt-get update && apt-get install -y \ python3-distutils \ python3-setuptools # Install necessary dependencies for MMS and SageMaker Inference Toolkit RUN apt-get update && \ apt-get -y install --no-install-recommends \ build-essential \ ca-certificates \ openjdk-8-jdk-headless \ python3-dev \ curl \ python3 \ vim \ && rm -rf /var/lib/apt/lists/* \ && curl -O https://bootstrap.pypa.io/pip/get-pip.py \ && curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \ && python3.7 get-pip.py --force-reinstall RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1 RUN update-alternatives --install /usr/local/bin/pip pip /usr/local/bin/pip3 1 # Install MXNet, MMS, and SageMaker Inference Toolkit to set up MMS RUN pip3 --no-cache-dir install multi-model-server \ sagemaker-inference \ retrying \ catboost \ pandas # Copy entrypoint script to the image COPY dockerd-entrypoint.py /usr/local/bin/dockerd-entrypoint.py RUN chmod +x /usr/local/bin/dockerd-entrypoint.py RUN echo "vmargs=-XX:-UseContainerSupport" >> /usr/local/lib/python3.7/dist-packages/sagemaker_inference/etc/mme-mms.properties RUN mkdir -p /home/model-server/ # Copy the default custom service file to handle incoming data and inference requests COPY model_handler.py /home/model-server/model_handler.py # Define an entrypoint script for the docker image ENTRYPOINT ["python", "/usr/local/bin/dockerd-entrypoint.py"] # Define command to be passed to the entrypoint CMD ["serve"]