|
| 1 | +# Multi-stage container for OpenAPI schema comparison |
| 2 | +# This container combines openapi-diff tool with yq for advanced YAML filtering |
| 3 | + |
| 4 | +# Stage 1: Download and prepare yq binary |
| 5 | +# We need a custom yq binary because the base openapi-diff container doesn't include it |
| 6 | +FROM debian:bullseye-slim AS downloader |
| 7 | + |
| 8 | +WORKDIR /tmp |
| 9 | + |
| 10 | +RUN apt-get update && apt-get install -y curl && \ |
| 11 | + apt-get clean && rm -rf /var/lib/apt/lists/* |
| 12 | + |
| 13 | +RUN curl -sSL https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -o /yq && \ |
| 14 | + chmod +x /yq |
| 15 | + |
| 16 | +# Stage 2: Final container with both openapi-diff and yq tools |
| 17 | +# Start from the official openapi-diff container which provides the core comparison functionality |
| 18 | +FROM openapitools/openapi-diff:2.1.2 |
| 19 | + |
| 20 | +WORKDIR /workspace |
| 21 | + |
| 22 | +# Copy the yq binary from the downloader stage to the final container |
| 23 | +# This gives us both tools in one container: openapi-diff for comparison and yq for filtering |
| 24 | +COPY --from=downloader /yq /usr/bin/yq |
| 25 | + |
| 26 | +WORKDIR /workspace |
| 27 | + |
| 28 | +# Environment variable containing the YAML filter condition |
| 29 | +# This filter focuses the comparison on only the most critical API endpoints: |
| 30 | +# - paths: Only specific API paths that are most critical for compatibility: |
| 31 | +# - /v1/inference: Core inference endpoints |
| 32 | +# - /v1/vector-io: Vector input/output operations |
| 33 | +# - /v1/vector-dbs: Vector database operations |
| 34 | +# - /v1/openai/v1/responses: OpenAI-compatible response formats |
| 35 | +# - /v1/openai/v1/chat: OpenAI-compatible chat endpoints |
| 36 | +# anything else (openapi, info, servers, is just there to make openapi-diff happy) |
| 37 | +ENV FILTER_CONDITION='{ "openapi": .openapi, "info": .info, "servers": .servers, "tags": .tags, "x-tagGroups": .["x-tagGroups"], "components": .components, "paths": (.paths | with_entries(select(.key | test("^/(v1/inference|v1/vector-io|v1/vector-dbs|v1/openai/v1/responses|v1/openai/v1/chat)")))) }' |
| 38 | + |
| 39 | +# Custom entrypoint that combines yq filtering with openapi-diff comparison |
| 40 | +# This allows us to compare only the filtered, relevant parts of the API spec |
| 41 | +ENTRYPOINT ["/bin/sh", "-c", "\ |
| 42 | + echo '=== Running yq filter ===' && \ |
| 43 | + # Filter the base branch OpenAPI spec to only relevant endpoints and save to base.yaml |
| 44 | + yq eval \"$FILTER_CONDITION\" /workspace/base/docs/_static/llama-stack-spec.yaml > /workspace/base.yaml && \ |
| 45 | + # Filter the current revision OpenAPI spec to only relevant endpoints and save to revision.yaml |
| 46 | + yq eval \"$FILTER_CONDITION\" /workspace/docs/_static/llama-stack-spec.yaml > /workspace/revision.yaml && \ |
| 47 | + echo '=== Running original openapi-diff entrypoint ===' && \ |
| 48 | + # Run the OpenAPI diff tool on the filtered specs |
| 49 | + exec java -jar /app/openapi-diff.jar /workspace/base.yaml /workspace/revision.yaml --fail-on-incompatible \ |
| 50 | +"] |
0 commit comments