Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM preprod-sklearn:1.4-2-py312
ADD . /app
WORKDIR /app
RUN python3 -m pip install .[test]
91 changes: 91 additions & 0 deletions docker/1.4-2-py312/base/Dockerfile.cpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
ARG UBUNTU_VERSION=24.04
ARG UBUNTU_IMAGE_DIGEST=b359f1067efa76f37863778f7b6d0e8d911e3ee8efa807ad01fbf5dc1ef9006b

# Build stage for SQLite compilation
FROM ubuntu:${UBUNTU_VERSION}@sha256:${UBUNTU_IMAGE_DIGEST} as sqlite-builder
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential wget ca-certificates && \
cd /tmp && \
wget https://www.sqlite.org/2025/sqlite-autoconf-3500200.tar.gz && \
tar xzf sqlite-autoconf-3500200.tar.gz && \
cd sqlite-autoconf-3500200 && \
./configure --prefix=/usr/local && \
make && \
make install && \
ldconfig && \
cd / && \
rm -rf /tmp/sqlite-autoconf-3500200 /tmp/sqlite-autoconf-3500200.tar.gz && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Main image
FROM ubuntu:${UBUNTU_VERSION}@sha256:${UBUNTU_IMAGE_DIGEST}

ARG PYTHON_VERSION=3.12

ENV DEBIAN_FRONTEND=noninteractive

# Install runtime dependencies only
RUN apt-get update && \
apt-get -y upgrade && \
apt-get -y install --no-install-recommends \
curl git jq libatlas-base-dev nginx openjdk-8-jdk-headless unzip wget expat tzdata apparmor \
libgstreamer1.0-0 libxml2 libsqlite3-0 software-properties-common ca-certificates lsb-release \
build-essential linux-libc-dev && \
# Add Apache Arrow repository for runtime libraries only
wget https://packages.apache.org/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb && \
apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb && \
apt-get update && \
apt-get install -y -V libarrow-dev=17.0.0-1 libarrow-dataset-dev=17.0.0-1 libparquet-dev=17.0.0-1 libarrow-acero-dev=17.0.0-1 && \
# Add deadsnakes PPA for Python 3.12
add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && \
apt-get -y install --no-install-recommends \
python3.12 python3.12-dev && \
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1 && \
# Create python symlink for backward compatibility
ln -sf /usr/bin/python3 /usr/bin/python && \
curl -sS https://bootstrap.pypa.io/get-pip.py | python3 - --break-system-packages && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN ln -fs /usr/share/zoneinfo/UTC /etc/localtime && \
dpkg-reconfigure --frontend noninteractive tzdata

# Install uv for fast Python package management
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
mv /root/.local/bin/uv /usr/local/bin/uv

ENV PATH=/usr/local/bin:${PATH}
ENV PIP_ROOT_USER_ACTION=ignore

# Copy compiled SQLite from builder stage
COPY --from=sqlite-builder /usr/local/bin/sqlite3 /usr/local/bin/sqlite3
COPY --from=sqlite-builder /usr/local/lib/libsqlite3.* /usr/local/lib/
COPY --from=sqlite-builder /usr/local/include/sqlite3*.h /usr/local/include/

# Update library cache and ensure /usr/local/bin is in PATH
RUN ldconfig && \
echo "/usr/local/lib" > /etc/ld.so.conf.d/sqlite3.conf && \
ldconfig

ENV PATH="/usr/local/bin:${PATH}"

# This command will check the version and print it to the build logs
RUN sqlite3 --version

# Install awscli
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && \
./aws/install && \
rm -r aws awscliv2.zip

# Python won't try to write .pyc or .pyo files on the import of source modules
# Force stdin, stdout and stderr to be totally unbuffered. Good for logging
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 PYTHONIOENCODING=UTF-8 LANG=C.UTF-8 LC_ALL=C.UTF-8

# Install core scientific packages with exact versions
RUN uv pip install --system --no-cache --break-system-packages \
numpy==2.1.0 \
scikit-learn==1.4.2 \
pyarrow==17.0.0
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM preprod-sklearn:1.4-2
FROM preprod-sklearn:1.4-2-py312

RUN pip freeze | grep -q 'scikit-learn==1.4.2'; \
if [ $? -eq 0 ]; \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
FROM sklearn-base:1.4-2
ENV SAGEMAKER_SKLEARN_VERSION 1.4-2
FROM sklearn-base:1.4-2-py312
ENV SAGEMAKER_SKLEARN_VERSION 1.4-2-py312
ENV PIP_ROOT_USER_ACTION=ignore

LABEL com.amazonaws.sagemaker.capabilities.accept-bind-to-port=true

# Install remaining packages via pip
COPY requirements.txt /requirements.txt
RUN uv pip install --system -r /requirements.txt && \
RUN uv pip install --system --break-system-packages -r /requirements.txt && \
rm /requirements.txt

# Fix Python 3.10 compatibility for sagemaker-containers
RUN python3 -c "import sys; import os; site_packages = '/usr/local/lib/python3.10/dist-packages'; mapping_file = os.path.join(site_packages, 'sagemaker_containers/_mapping.py'); exec('if os.path.exists(mapping_file):\\n with open(mapping_file, \"r\") as f:\\n content = f.read()\\n content = content.replace(\"collections.Mapping\", \"collections.abc.Mapping\")\\n with open(mapping_file, \"w\") as f:\\n f.write(content)')"
# Fix Python 3.12 compatibility for sagemaker-containers
RUN python3 -c "import sys; import os; site_packages = '/usr/local/lib/python3.12/dist-packages'; mapping_file = os.path.join(site_packages, 'sagemaker_containers/_mapping.py'); exec('if os.path.exists(mapping_file):\\n with open(mapping_file, \"r\") as f:\\n content = f.read()\\n content = content.replace(\"collections.Mapping\", \"collections.abc.Mapping\")\\n with open(mapping_file, \"w\") as f:\\n f.write(content)')"

COPY dist/sagemaker_sklearn_container-2.0-py3-none-any.whl /sagemaker_sklearn_container-2.0-py3-none-any.whl
RUN uv pip install --system --no-cache /sagemaker_sklearn_container-2.0-py3-none-any.whl && \
RUN uv pip install --system --no-cache --break-system-packages /sagemaker_sklearn_container-2.0-py3-none-any.whl && \
rm /sagemaker_sklearn_container-2.0-py3-none-any.whl

# Force upgrade six to 1.16.0 after all packages are installed to ensure six.moves compatibility
RUN uv pip install --system --break-system-packages --upgrade --force-reinstall six==1.16.0

# Configure pip to always use --break-system-packages for Python 3.12
RUN mkdir -p /root/.config/pip && \
echo "[global]" > /root/.config/pip/pip.conf && \
echo "break-system-packages = true" >> /root/.config/pip/pip.conf

ENV SAGEMAKER_TRAINING_MODULE sagemaker_sklearn_container.training:main
ENV SAGEMAKER_SERVING_MODULE sagemaker_sklearn_container.serving:main

Expand Down Expand Up @@ -56,4 +64,4 @@ EXPOSE 8080
ENV TEMP=/home/model-server/tmp

# Required label for multi-model loading
LABEL com.amazonaws.sagemaker.capabilities.multi-models=true
LABEL com.amazonaws.sagemaker.capabilities.multi-models=true
193 changes: 0 additions & 193 deletions docker/1.4-2/base/Dockerfile.cpu

This file was deleted.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
name = "sagemaker-sklearn-container"
version = "2.0"
description = "SageMaker Scikit-learn Container"
requires-python = "==3.10.*"
license = "Apache-2.0"
requires-python = "==3.12.*"
license = {text = "Apache-2.0"}
authors = [{name = "Amazon Web Services"}]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Natural Language :: English",
"Programming Language :: Python",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.12",
]
dynamic = ["readme", "dependencies", "optional-dependencies"]

Expand All @@ -31,4 +31,4 @@ where = ["src"]
exclude = ["test*"]

[tool.setuptools.package-dir]
"" = "src"
"" = "src"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sagemaker-containers==2.8.6.post2
sagemaker-inference==1.2.0
sagemaker-training==4.8.0
setuptools==80.9.0
six==1.15.0
six==1.16.0
urllib3==1.26.17
Werkzeug==2.0.3
wheel==0.45.1
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def read(fname):
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.12",
],

install_requires=read("requirements.txt"),
Expand All @@ -47,5 +48,5 @@ def read(fname):
'console_scripts': 'serve=sagemaker_sklearn_container.serving:serving_entrypoint'
},

python_requires='>=3.10',
python_requires='>=3.12',
)
Loading