# Based on https://github.com/aws/amazon-sagemaker-examples/blob/main/advanced_functionality/scikit_bring_your_own/container/Dockerfile # Run in the project root directory: # pip install sagemaker-studio-image-build # sm-docker build . --file tests/byoc/Dockerfile.internet_free --repo byoc-ssh-no-internet:latest # See tests/test_frameworks.py::test_train_internet_free_ssh # See https://aws.amazon.com/blogs/machine-learning/using-the-amazon-sagemaker-studio-image-build-cli-to-build-container-images-from-your-studio-notebooks/ . # Also see https://medium.com/@pandey.vikesh/why-bring-your-own-container-to-amazon-sagemaker-and-how-to-do-it-right-bc158fe41ed1 . FROM public.ecr.aws/docker/library/ubuntu:20.04 RUN apt-get -y update && apt-get install -y --no-install-recommends \ wget \ python3-pip \ python3-setuptools \ nginx \ ca-certificates \ && rm -rf /var/lib/apt/lists/* RUN ln -s /usr/bin/python3 /usr/bin/python RUN pip --no-cache-dir install numpy scipy scikit-learn pandas flask gunicorn # Install SageMaker SSH Helper for the Internet-free setup ARG SAGEMAKER_SSH_HELPER_DIR="/opt/sagemaker-ssh-helper" RUN mkdir -p $SAGEMAKER_SSH_HELPER_DIR RUN pip3 uninstall -y -q awscli # Install official release (for users): #RUN \ # pip3 install --no-cache-dir sagemaker-ssh-helper # Install dev release from source (for developers): COPY ./ $SAGEMAKER_SSH_HELPER_DIR/src/ RUN \ pip3 --no-cache-dir install wheel && \ pip3 --no-cache-dir install $SAGEMAKER_SSH_HELPER_DIR/src/ # Pre-configure the container with packages, which should be installed from Internet RUN sm-setup-ssh configure ENV PYTHONUNBUFFERED=TRUE ENV PYTHONDONTWRITEBYTECODE=TRUE ENV PATH="/opt/program:${PATH}" COPY tests/byoc/decision_trees /opt/program WORKDIR /opt/program