Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
56 changes: 34 additions & 22 deletions microservices/time-series-analytics/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,57 @@
# SPDX-License-Identifier: Apache-2.0
#

# Use the Kapacitor image as the base image
ARG KAPACITOR_VERSION
FROM kapacitor:$KAPACITOR_VERSION as builder
# Use Python Debian image as the base image
ARG PYTHON_VERSION
FROM python:${PYTHON_VERSION}-slim as builder

# Install Python and necessary packages in a single layer, minimize image size
# Install git to clone Kapacitor Python UDF agent files
RUN apt-get update && \
apt-get install -y --no-install-recommends git
apt-get install -y --no-install-recommends git && \
rm -rf /var/lib/apt/lists/*

ARG KAPACITOR_VERSION
# Clone only the required files to reduce image size
RUN git clone --depth 1 --filter=blob:none --sparse --branch v${KAPACITOR_VERSION} \
https://github.com/influxdata/kapacitor.git /tmp/kapacitor && \
cd /tmp/kapacitor && \
git sparse-checkout set udf/agent/py

FROM kapacitor:$KAPACITOR_VERSION as runtime
ARG PYTHON_VERSION
FROM python:${PYTHON_VERSION}-slim as runtime


ARG INSTALL_DRIVER_VERSION="24.26.30049"
ENV INSTALL_DRIVER_VERSION=${INSTALL_DRIVER_VERSION}

RUN apt-get update && \
apt-get install -y --no-install-recommends curl && \
rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Install Kapacitor and other necessary packages
ARG KAPACITOR_DEBIAN_PACKAGE_VERSION
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3 python3-pip intel-gpu-tools && \
apt-get purge -y --auto-remove && \
wget intel-gpu-tools && \
mkdir -p /etc/init.d && \
wget -O /tmp/kapacitor.deb "https://dl.influxdata.com/kapacitor/releases/kapacitor_${KAPACITOR_DEBIAN_PACKAGE_VERSION}.deb" || exit 1 && \
dpkg -i /tmp/kapacitor.deb || true && \
apt-get install -y -f --no-install-recommends && \
rm -f /tmp/kapacitor.deb && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /root/.cache/pip

# Copy kapacitor Python UDF agent files from builder image
COPY --from=builder /tmp/kapacitor/udf/agent/py /app/kapacitor_python

RUN apt-get update && apt-get install -y libnuma1 ocl-icd-libopencl1 --no-install-recommends && rm -rf /var/lib/apt/lists/* && \
mkdir /tmp/gpu_deps && cd /tmp/gpu_deps && \
curl --fail -L -O https://github.com/intel/compute-runtime/releases/download/25.13.33276.16/intel-level-zero-gpu_1.6.33276.16_amd64.deb && \
curl --fail -L -O https://github.com/intel/compute-runtime/releases/download/25.13.33276.16/intel-opencl-icd_25.13.33276.16_amd64.deb && \
curl --fail -L -O https://github.com/intel/compute-runtime/releases/download/25.13.33276.16/libigdgmm12_22.7.0_amd64.deb && \
curl --fail -L -O https://github.com/intel/intel-graphics-compiler/releases/download/v2.10.8/intel-igc-core-2_2.10.8+18926_amd64.deb && \
curl --fail -L -O https://github.com/intel/intel-graphics-compiler/releases/download/v2.10.8/intel-igc-opencl-2_2.10.8+18926_amd64.deb && \
dpkg -i *.deb && rm -Rf /tmp/gpu_deps
COPY scripts/install_ubuntu_gpu_drivers.sh /tmp/install_gpu_drivers.sh
RUN chmod +x /tmp/install_gpu_drivers.sh && \
/tmp/install_gpu_drivers.sh && \
apt-get clean && rm -rf /tmp/install_gpu_drivers.sh && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/*

ARG TIMESERIES_UID
ARG TIMESERIES_USER_NAME
ARG PYTHON_VERSION

# Create non-root user and group in a single layer for smaller image and better caching
RUN groupadd --gid $TIMESERIES_UID $TIMESERIES_USER_NAME && \
Expand All @@ -51,7 +63,7 @@ RUN groupadd --gid $TIMESERIES_UID $TIMESERIES_USER_NAME && \
COPY ./requirements.txt .

# Install Python dependencies efficiently and clean up cache to reduce image size
RUN pip3 install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Set environment variables in a single ENV instruction for better layer caching
ENV PYTHONPATH="$PYTHONPATH:/tmp/py_package:/app/kapacitor_python/"
Expand Down Expand Up @@ -88,12 +100,12 @@ RUN if [ "$COPYLEFT_SOURCES" = "true" ]; then \
cd /copyleft_sources/python && \
apt-get update && apt-get install -y --no-install-recommends gcc libffi-dev python3-dev && \
# Download python package sources with relevant licenses \
pip3 freeze | cut -d= -f1 | while read pkg; do \
meta=$(pip3 show $pkg 2>/dev/null); \
pip freeze | cut -d= -f1 | while read pkg; do \
meta=$(pip show $pkg 2>/dev/null); \
lic=$(echo "$meta" | grep -i '^License:' | grep -E 'MPL|GPL|General Public License|EPL|Eclipse Public License|CDDL|LGPL'); \
if [ ! -z "$lic" ]; then \
echo "Downloading source for $pkg with license: $lic"; \
pip3 download --no-binary :all: $pkg || true; \
pip download --no-binary :all: $pkg || true; \
fi; \
done; \
apt-get remove --purge -y gcc libffi-dev python3-dev; \
Expand All @@ -110,4 +122,4 @@ USER $TIMESERIES_USER_NAME
# Simple healthcheck to verify container is running
HEALTHCHECK --interval=5m CMD exit 0

ENTRYPOINT ["python3", "main.py"]
ENTRYPOINT ["python", "main.py"]
5 changes: 4 additions & 1 deletion microservices/time-series-analytics/docker/.env
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ timeseries_no_proxy=localhost,127.0.0.1

KAPACITOR_PORT=9092
LOG_LEVEL=INFO
TIME_SERIES_ANALYTICS_IMAGE=intel/ia-time-series-analytics-microservice:1.1.0
# Python version to be used in the Dockerfile
PYTHON_VERSION=3.10

TIME_SERIES_ANALYTICS_IMAGE=intel/ia-time-series-analytics-microservice:1.2.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rebase w/ latest main.

# Please provide the suffix for the image version you want to use like rc1, rc2, git hash id etc.
IMAGE_SUFFIX="weekly"
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/bin/bash -x
#
# Copyright (c) 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Script should be used only as a part of Dockerfiles

# Check if INSTALL_DRIVER_VERSION is set
# In case it is not set we reach default switch condition and leave apt in abnormal state
if [ -z "$INSTALL_DRIVER_VERSION" ]; then
echo "Error: INSTALL_DRIVER_VERSION cannot be empty."
exit 1
fi

apt-get update && apt-get install -y libnuma1 ocl-icd-libopencl1 --no-install-recommends && rm -rf /var/lib/apt/lists/* && \
case $INSTALL_DRIVER_VERSION in \
"24.26.30049") \
mkdir /tmp/gpu_deps && cd /tmp/gpu_deps ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/24.26.30049.6/intel-level-zero-gpu_1.3.30049.6_amd64.deb ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/24.26.30049.6/intel-opencl-icd_24.26.30049.6_amd64.deb ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/24.26.30049.6/libigdgmm12_22.3.20_amd64.deb ; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.17193.4/intel-igc-core_1.0.17193.4_amd64.deb ; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.17193.4/intel-igc-opencl_1.0.17193.4_amd64.deb ; \
dpkg -i *.deb && rm -Rf /tmp/gpu_deps ; \
;; \
"24.39.31294") \
mkdir /tmp/gpu_deps && cd /tmp/gpu_deps ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/24.39.31294.12/intel-level-zero-gpu_1.6.31294.12_amd64.deb ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/24.39.31294.12/intel-opencl-icd_24.39.31294.12_amd64.deb ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/24.39.31294.12/libigdgmm12_22.5.2_amd64.deb ; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.17791.9/intel-igc-core_1.0.17791.9_amd64.deb ; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.17791.9/intel-igc-opencl_1.0.17791.9_amd64.deb ; \
dpkg -i *.deb && rm -Rf /tmp/gpu_deps ; \
;; \
"24.52.32224") \
mkdir /tmp/gpu_deps && cd /tmp/gpu_deps ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/24.52.32224.5/intel-level-zero-gpu_1.6.32224.5_amd64.deb ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/24.52.32224.5/intel-opencl-icd_24.52.32224.5_amd64.deb ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/24.52.32224.5/libigdgmm12_22.5.5_amd64.deb ; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/v2.5.6/intel-igc-core-2_2.5.6+18417_amd64.deb ; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/v2.5.6/intel-igc-opencl-2_2.5.6+18417_amd64.deb ; \
dpkg -i *.deb && rm -Rf /tmp/gpu_deps ; \
;; \
"25.31.34666") \
mkdir /tmp/gpu_deps && cd /tmp/gpu_deps ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/25.31.34666.3/libze-intel-gpu1_25.31.34666.3-0_amd64.deb; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/25.31.34666.3/intel-opencl-icd_25.31.34666.3-0_amd64.deb; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/25.31.34666.3/libigdgmm12_22.8.1_amd64.deb; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/25.31.34666.3/intel-ocloc_25.31.34666.3-0_amd64.deb; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/v2.16.0/intel-igc-core-2_2.16.0+19683_amd64.deb; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/v2.16.0/intel-igc-opencl-2_2.16.0+19683_amd64.deb; \
dpkg -i *.deb && rm -Rf /tmp/gpu_deps ; \
;; \
"25.35.35096") \
mkdir /tmp/gpu_deps && cd /tmp/gpu_deps ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/25.35.35096.9/libze-intel-gpu1_25.35.35096.9-0_amd64.deb; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/25.35.35096.9/intel-opencl-icd_25.35.35096.9-0_amd64.deb; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/25.35.35096.9/libigdgmm12_22.8.1_amd64.deb; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/25.35.35096.9/intel-ocloc_25.35.35096.9-0_amd64.deb; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/v2.18.5/intel-igc-core-2_2.18.5+19820_amd64.deb; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/v2.18.5/intel-igc-opencl-2_2.18.5+19820_amd64.deb; \
dpkg -i *.deb && rm -Rf /tmp/gpu_deps ; \
;; \
"25.48.36300") \
mkdir /tmp/gpu_deps && cd /tmp/gpu_deps ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/25.48.36300.8/libze-intel-gpu1_25.48.36300.8-0_amd64.deb; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/25.48.36300.8/intel-opencl-icd_25.48.36300.8-0_amd64.deb; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/25.48.36300.8/libigdgmm12_22.8.2_amd64.deb; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/25.48.36300.8/intel-ocloc_25.48.36300.8-0_amd64.deb; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/v2.24.8/intel-igc-core-2_2.24.8+20344_amd64.deb; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/v2.24.8/intel-igc-opencl-2_2.24.8+20344_amd64.deb; \
dpkg -i *.deb && rm -Rf /tmp/gpu_deps ; \
;; \
*) \
dpkg -P intel-gmmlib intel-igc-core intel-igc-opencl intel-level-zero-gpu intel-ocloc intel-opencl intel-opencl-icd && \
apt-get update && apt-get -y --no-install-recommends install dpkg-dev && rm -rf /var/lib/apt/lists/* && \
cd /drivers/${INSTALL_DRIVER_VERSION} && \
dpkg-scanpackages . > Packages && \
cd - ; \
echo "deb [trusted=yes arch=amd64] file:/drivers/${INSTALL_DRIVER_VERSION} ./" > /etc/apt/sources.list.d/intel-graphics-${INSTALL_DRIVER_VERSION}.list ; \
apt-get update && \
apt-get install -y --no-install-recommends \
intel-opencl-icd \
intel-level-zero-gpu level-zero \
intel-media-va-driver-non-free libmfx1 && \
rm -rf /var/lib/apt/lists/* ; \
esac

apt-get clean && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/*
Loading
Loading