diff --git a/docs/rest_api/Makefile b/docs/rest_api/Makefile new file mode 100644 index 0000000000..181b2a0d35 --- /dev/null +++ b/docs/rest_api/Makefile @@ -0,0 +1,22 @@ +include ../../Makefile.shared + +RESTAPI_BUILD_DIR := ${TARGET_DIR}/rest_api + +.PHONY: build + +# Replaces all ${TAG} placeholders with the current build version +build: + @echo "Building REST API..." + @mkdir -p $(RESTAPI_BUILD_DIR) + + @echo "Copying source files..." + @rsync -av --exclude='Makefile' --exclude='.build' . $(RESTAPI_BUILD_DIR) + + @echo "Processing OpenAPI specifications..." + @for file in openapi.yaml openapi_internal.yaml; do \ + echo "Processing $$file..."; \ + TAG=$(TAG) envsubst '$$TAG' < $(RESTAPI_BUILD_DIR)/$$file > $(RESTAPI_BUILD_DIR)/$$file.tmp; \ + mv $(RESTAPI_BUILD_DIR)/$$file.tmp $(RESTAPI_BUILD_DIR)/$$file; \ + done + + @echo "Build complete" diff --git a/docs/rest_api/openapi.yaml b/docs/rest_api/openapi.yaml index 51008cc6ab..1eaefffb55 100644 --- a/docs/rest_api/openapi.yaml +++ b/docs/rest_api/openapi.yaml @@ -1,6 +1,6 @@ openapi: "3.1.0" info: - version: 2.12.0 + version: ${TAG} title: Intel® Geti™ REST API description: REST API documentation for Intel® Geti™. diff --git a/docs/rest_api/openapi_internal.yaml b/docs/rest_api/openapi_internal.yaml index 9be49d0729..38267b485f 100644 --- a/docs/rest_api/openapi_internal.yaml +++ b/docs/rest_api/openapi_internal.yaml @@ -1,6 +1,6 @@ openapi: "3.1.0" info: - version: 2.12.0 + version: ${TAG} title: Intel® Geti™ REST API description: REST API documentation for Intel® Geti™. diff --git a/interactive_ai/tests/e2e/Makefile b/interactive_ai/tests/e2e/Makefile index 9580082477..c986f9da91 100644 --- a/interactive_ai/tests/e2e/Makefile +++ b/interactive_ai/tests/e2e/Makefile @@ -1,16 +1,28 @@ MAKEFILE_DIR := $(shell pwd) -OPENAPI_YAML_SPEC := ../../../docs/rest_api/openapi_internal.yaml + +OPENAPI_DIR := ../../../docs/rest_api + +OPENAPI_YAML_SPEC := $(OPENAPI_DIR)/.build/rest_api/openapi_internal.yaml OPENAPI_JSON_SPEC := /tmp/openapi_internal.json CLIENT_NAME := geti_client CLIENT_PATH := rest_client SPEC_HASH_FILE := .openapi_spec_hash -.PHONY: all check_yaml_spec generate_json_spec generate_client generate_client_if_needed test test_wip test_smoke mypy +.PHONY: all check_yaml_spec generate_json_spec generate_client generate_client_if_needed test test_wip test_smoke mypy compile_yaml_spec venv: $(MAKE) generate_client_if_needed; uv sync --frozen ${PIP_INSTALL_PARAMS} -check_yaml_spec: + +compile_yaml_spec: + @if [ ! -d $(OPENAPI_DIR) ]; then \ + echo "Error: OpenAPI directory not found at $(OPENAPI_DIR)"; \ + exit 1; \ + else \ + $(MAKE) -C $(OPENAPI_DIR) build; \ + fi + +check_yaml_spec: compile_yaml_spec @if [ ! -f $(OPENAPI_YAML_SPEC) ]; then \ echo "Error: OpenAPI YAML spec file not found at $(OPENAPI_YAML_SPEC)"; \ exit 1; \ diff --git a/web_ui/Dockerfile b/web_ui/Dockerfile index b8ecab972b..1c15e8f2ac 100644 --- a/web_ui/Dockerfile +++ b/web_ui/Dockerfile @@ -7,6 +7,7 @@ FROM node:22.12-bookworm-slim@sha256:35531c52ce27b6575d69755c73e65d4468dba93a25644eed56dc12879cae9213 AS build_rest_api_specs ARG LOCATION=/home/app/rest-api-specs/ +ARG REACT_APP_GETI_VERSION=development WORKDIR ${LOCATION} @@ -14,6 +15,15 @@ COPY --link ./package.json . COPY --link --from=docs_context rest_api /home/app/docs/rest_api/ COPY --link --from=api_context schemas /home/app/interactive_ai/services/api/schemas/ +# Install envsubst +RUN apt-get update && apt-get install -y gettext-base && rm -rf /var/lib/apt/lists/* + +# Replace ${TAG} placeholders with the current build version +RUN TAG=${REACT_APP_GETI_VERSION} envsubst '$$TAG' < /home/app/docs/rest_api/openapi.yaml > /home/app/docs/rest_api/openapi.yaml.tmp && \ + mv /home/app/docs/rest_api/openapi.yaml.tmp /home/app/docs/rest_api/openapi.yaml && \ + TAG=${REACT_APP_GETI_VERSION} envsubst '$$TAG' < /home/app/docs/rest_api/openapi_internal.yaml > /home/app/docs/rest_api/openapi_internal.yaml.tmp && \ + mv /home/app/docs/rest_api/openapi_internal.yaml.tmp /home/app/docs/rest_api/openapi_internal.yaml + RUN npm run build:rest-openapi-spec @@ -43,8 +53,8 @@ COPY --link ./dev-proxy.ts ./ COPY --link src/ src/ COPY --link public/ public/ -COPY --from=docs_context rest_api /home/app/docs/rest_api/ -COPY --from=api_context schemas /home/app/interactive_ai/services/api/schemas/ +COPY --from=build_rest_api_specs /home/app/docs/rest_api/ /home/app/docs/rest_api/ +COPY --from=build_rest_api_specs /home/app/interactive_ai/services/api/schemas/ /home/app/interactive_ai/services/api/schemas/ RUN npm run build