blob: 2aa5d3eea74c809defbb3a92ec51e2875d656041 [file] [log] [blame]
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
# Multi-stage build for Python SDK testing
FROM python:3.11-slim AS base
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install Rust for maturin
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
# Set working directory
WORKDIR /workspace
# Copy dependency files first for better layer caching
COPY Cargo.toml Cargo.lock ./
COPY foreign/python/Cargo.toml ./foreign/python/
COPY foreign/python/pyproject.toml ./foreign/python/
COPY foreign/python/README.md ./foreign/python/
COPY foreign/python/LICENSE ./foreign/python/
COPY foreign/python/NOTICE ./foreign/python/
# Install build dependencies
WORKDIR /workspace/foreign/python
RUN pip install --no-cache-dir maturin
# Copy core dependencies (changes less frequently)
COPY core/ /workspace/core/
# Copy Python SDK source (changes more frequently)
COPY foreign/python/src/ ./src/
# Build Python SDK and install wheel
RUN maturin build
RUN find target/wheels/ -name "*.whl" -exec pip install {} \;
# Install test dependencies from pyproject.toml
RUN pip install --no-cache-dir -e ".[testing]"
# Copy test files
COPY foreign/python/tests/ ./tests/
# Create test script
COPY foreign/python/scripts/test.sh ./scripts/test.sh
RUN chmod +x ./scripts/test.sh
# Set environment variables
ENV PYTHONPATH=/workspace/foreign/python
ENV IGGY_SERVER_HOST=iggy-server
ENV IGGY_SERVER_TCP_PORT=8090
# Default command runs tests
CMD ["./scripts/test.sh"]