LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
# Use a specific version of Python slim image
FROM python:3.12-slim-trixie AS base
LABEL maintainer="Zipstack Inc." \
description="Runner Service Container"
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/unstract \
BUILD_CONTEXT_PATH=runner \
BUILD_PACKAGES_PATH=unstract \
APP_HOME=/app \
# OpenTelemetry configuration (disabled by default, enable in docker-compose)
OTEL_TRACES_EXPORTER=none \
OTEL_METRICS_EXPORTER=none \
OTEL_LOGS_EXPORTER=none \
OTEL_SERVICE_NAME=unstract_runner
# Install system dependencies
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN apt-get update \
&& apt-get --no-install-recommends install -y \
ca-certificates \
curl \
gnupg \
lsb-release \
git \
&& curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null \
&& apt-get update \
&& apt-get --no-install-recommends install -y docker-ce-cli \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
# Install uv package manager
COPY --from=ghcr.io/astral-sh/uv:0.6.14 /uv /uvx /bin/
# Create working directory
WORKDIR ${APP_HOME}
# -----------------------------------------------
# EXTERNAL DEPENDENCIES STAGE - This layer gets cached if external dependencies don't change
# -----------------------------------------------
FROM base AS ext-dependencies
# Copy dependency-related files
COPY ${BUILD_CONTEXT_PATH}/pyproject.toml ${BUILD_CONTEXT_PATH}/uv.lock ${BUILD_CONTEXT_PATH}/README.md ./
# Copy local package dependencies
COPY ${BUILD_PACKAGES_PATH}/core /unstract/core
COPY ${BUILD_PACKAGES_PATH}/flags /unstract/flags
# Increase timeout for large packages (flipt-client is ~45MB)
ENV UV_HTTP_TIMEOUT=120
# Install external dependencies from pyproject.toml
RUN uv sync --group deploy --locked --no-install-project --no-dev
# -----------------------------------------------
# FINAL STAGE - Minimal image for production
# -----------------------------------------------
FROM ext-dependencies AS production
# Set shell options for better error handling
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Copy application code (this layer changes most frequently)
COPY ${BUILD_CONTEXT_PATH} ./
# Install the application
RUN uv sync --group deploy --no-dev --locked
# Install cloud requirements if they exist and setup OTEL
RUN if [ -f cloud_requirements.txt ]; then \
uv pip install -r cloud_requirements.txt; \
else \
echo "cloud_requirements.txt does not exist"; \
fi && \
uv run opentelemetry-bootstrap -a requirements | uv pip install --requirement -
EXPOSE 5002
ARG VERSION=dev
ENV UNSTRACT_APPS_VERSION=${VERSION}
CMD [ "./entrypoint.sh" ]