Customizing Python and SPSS deployment images

You can add customizations to your Python and SPSS images by using Docker or Podman.

Adding customizations to Python image

Note:
  • If you're bringing back the discontinued Spark 3.3 image, no customization is required.
  • If you are building a custom image for a custom foundation model:
    • You must prepare Python code that exposes the relevant Completions API and starts the Rest API server to expose the API. Add commands that copy this Python code into the Docker image.
    • Make sure that your custom image exposes port 3000. Otherwise, inferencing won't work.

Refer to the following sample Dockerfile to add customizations to your Python image.

ARG  base_image_tag
FROM ${base_image_tag}

# For installing system packages, use root:root
# e.g.
USER root:root
RUN microdnf install -y jq

# For installing to conda site-packages,
# use wsbuild:wsbuild
# e.g.
USER wsbuild:wsbuild
RUN source $WML_DEPLOYMENT_VENV/bin/activate && \
   $WML_DEPLOYMENT_VENV/bin/pip install pendulum
USER wsuser:wsbuild

You can run this Dockerfile by using the docker build command, which returns the following output sample:

docker build -t wml-demo-image:test-1 --build-arg base_image_tag=cp.stg.icr.io/cp/cpd/wml-dep-rt-251-py@sha256:b7c15be2d331fcafec349de531440dac7296fefcc42676fd34266d572b74d3e1 -f Dockerfile .
[+] Building 12.1s (7/7) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                   0.0s
 => => transferring dockerfile: 400B                                                                                                                                                                   0.0s
 => [internal] load .dockerignore                                                                                                                                                                      0.0s
 => => transferring context: 2B                                                                                                                                                                        0.0s
 => [internal] load metadata for cp.stg.icr.io/cp/cpd/wml-dep-rt-251-py@sha256:b7c15be2d331fcafec349de531440dac7296fefcc42676fd34266d572b74d3e1                                                        0.0s
 => [1/3] FROM cp.stg.icr.io/cp/cpd/wml-dep-rt-251-py@sha256:b7c15be2d331fcafec349de531440dac7296fefcc42676fd34266d572b74d3e1                                                                          0.2s
 => [2/3] RUN microdnf install -y jq                                                                                                                                                                   7.0s
 => [3/3] RUN source /opt/user-env/pyt6xc/bin/activate &&    /opt/user-env/pyt6xc/bin/pip install pendulum                                                                                             4.5s
 => exporting to image                                                                                                                                                                                 0.3s
 => => exporting layers                                                                                                                                                                                0.2s
 => => writing image sha256:47e1e060d8a748b9b12859743badb892124a14c119a7c706d1f2f80861c87d33                                                                                                           0.0s
 => => naming to docker.io/library/wml-demo-image:test-1

To use the sample code, you must update the following parameters:

  • Set user:group parameter to root:root to install system packages.
  • After installing system packages, set user:group parameter to wsbuild:wsbuild to install python packages.
  • After updating the conda environment, set user:group to wsuser:wscommon.

You can also run the Dockerfile in Podman by using the podman build command, which returns the following output sample:

 podman build -t wml-demo-image:test-1 \
    --build-arg base_image_tag=$BASE_IMAGE \
    -f Dockerfile
STEP 1/6: FROM cp.stg.icr.io/cp/cpd/wml-dep-rt-251-py@sha256:b7c15be2d331fcafec349de531440dac7296fefcc42676fd34266d572b74d3e1
STEP 2/6: USER root:root
--> 5c02bf3d2611
STEP 3/6: RUN microdnf install -y jq
Downloading metadata...
STEP 4/6: USER wsbuild:wsbuild
--> a71bec1afd05
STEP 5/6: RUN source $WML_DEPLOYMENT_VENV/bin/activate &&    $WML_DEPLOYMENT_VENV/bin/pip install xxxxx
--> 34a45526d163
STEP 6/6: USER 1000321000:103000
COMMIT wml-demo-image:test-1
--> dcd1b3899741
Successfully tagged localhost/wml-demo-image:test-1
dcd1b3899741aa5ba87ac48b5792a667fb48eb2328c89eeb4123f23a215792fb
Tip:

As best practice, set the default USER of the custom image to wsuser:wscommon. The HOME environment variable is set to /home/wsuser in the deployment service.

Adding customizations to your SPSS image

Refer to the following sample Dockerfile to add customizations to your SPSS image:

FROM <SPSS_RUNTIME_IMAGE> AS custom_image
 # Install Exasol ODBC driver
 RUN mkdir -p /opt/exasol
 RUN wget -O /opt/exasol/EXASOL_ODBC.tar.gz \
           https://www.exasol.com/support/secure/attachment/175398/EXASOL_ODBC-${EXASOL_ODBC_VERSION}.tar.gz
              RUN ls -l /opt/exasol/EXASOL_ODBC.tar.gz
RUN cd /opt/exasol \
 && tar -xzf EXASOL_ODBC.tar.gz
RUN mv  /opt/exasol/EXASolution_ODBC-${EXASOL_ODBC_VERSION}/* /opt/exasol
RUN rm -rf /opt/exasol/EXASolution_ODBC-${EXASOL_ODBC_VERSION} \
    && rm -rf /opt/exasol/EXASOL_ODBC.tar.gz
# enable Exasol ODBC Driver
RUN sed -i '2iExasol Client=Installed' ${SDAPDRIVER_HOME}/odbcinst.ini
USER ${BASE_USER_NAME}