From e87e9518ec149d5f71f003c43379f66a32fc93ee Mon Sep 17 00:00:00 2001 From: Hubert Date: Mon, 20 Oct 2025 12:22:05 +0200 Subject: [PATCH 1/4] OCM package with local tests --- .github/workflows/on-release.yaml | 16 ++++ .gitignore | 3 + Dockerfile | 1 + Taskfile.yml | 142 ++++++++++++++++++++++++++++ ocm/component-descriptor-local.yaml | 13 +++ ocm/component-descriptor.yaml | 13 +++ 6 files changed, 188 insertions(+) create mode 100644 Taskfile.yml create mode 100644 ocm/component-descriptor-local.yaml create mode 100644 ocm/component-descriptor.yaml diff --git a/.github/workflows/on-release.yaml b/.github/workflows/on-release.yaml index ec6f6a8a..ff5f7a42 100644 --- a/.github/workflows/on-release.yaml +++ b/.github/workflows/on-release.yaml @@ -71,6 +71,22 @@ jobs: sbom: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.event.inputs.nextVersion }} + - name: Install OCM CLI + run: | + sudo curl -sL https://raw.githubusercontent.com/open-component-model/ocm/main/install.sh | sudo bash + + - name: Install Go-Task + uses: arduino/setup-task@v2 + with: + version: 3.x + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Build OCM component + run: task build:ocm -- ${{ github.event.inputs.nextVersion }} + + - name: Publish OCM component + run: task publish:ocm + - name: Create Release with autogenerated release notes env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index ed12b496..2d0ce0cf 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ public/frontend-config.json # Sentry Config File .env.sentry-build-plugin + +# OCM build artifacts +.ctf/ diff --git a/Dockerfile b/Dockerfile index d4544f83..a5c104f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,7 @@ RUN npm ci # Build ENV NODE_ENV=production +ENV NODE_OPTIONS=--max-old-space-size=4096 COPY . . RUN npm run build diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 00000000..6076d328 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,142 @@ +version: "3" + +vars: + # Variables for Docker image + REGISTRY: ghcr.io/openmcp-project + IMAGE_NAME: mcp-ui-frontend + IMAGE_TAG: '{{.TAG | default "latest"}}' + DOCKER_IMAGE: "{{.REGISTRY}}/{{.IMAGE_NAME}}:{{.IMAGE_TAG}}" + + # Variables for local testing + LOCAL_REGISTRY: localhost:5000 + LOCAL_IMAGE_NAME: mcp-ui-frontend + LOCAL_DOCKER_IMAGE: "{{.LOCAL_REGISTRY}}/{{.LOCAL_IMAGE_NAME}}:{{.IMAGE_TAG}}" + + # Variables for OCM component + OCM_COMPONENT_NAME: github.com/openmcp-project/ui + OCM_COMPONENT_VERSION: '{{.OCM_COMPONENT_VERSION | default .IMAGE_TAG}}' + OCM_PROVIDER: openmcp-project + OCM_TARGET_REPO: '{{.OCM_TARGET_REPO | default (print .REGISTRY "/components") }}' + OCM_OUTPUT_DIR: "{{.ROOT_DIR}}/.ctf" + OCM_DESCRIPTOR: "{{.ROOT_DIR}}/ocm/component-descriptor.yaml" + +tasks: + default: + desc: Show available tasks + cmds: + - task --list + + build:ocm: + desc: "Builds the ocm component. Usage: task build:ocm -- " + cmds: + - rm -rf {{.OCM_OUTPUT_DIR}} + - | + ocm add components --create --force --copy-resources \ + --complete \ + --lookup {{.OCM_TARGET_REPO}} \ + --file {{.OCM_OUTPUT_DIR}} \ + {{.OCM_DESCRIPTOR}} -- \ + VERSION={{.OCM_COMPONENT_VERSION}} \ + COMPONENT_NAME={{.OCM_COMPONENT_NAME}} \ + PROVIDER={{.OCM_PROVIDER}} + vars: + OCM_COMPONENT_VERSION: '{{.CLI_ARGS}}' + + publish:ocm: + desc: "Publishes the ocm component to the registry." + cmds: + - | + ocm transfer ctf \ + --copy-resources \ + --enforce --overwrite \ + {{.OCM_OUTPUT_DIR}} {{.OCM_TARGET_REPO}} + + # Those tasks are only for local testing purposes + + test:inspect-ocm: + desc: "Inspects the locally built OCM component. Usage: task test:inspect-ocm -- " + cmds: + - echo "--- Component Details ---" + - ocm get component -o yaml {{.OCM_COMPONENT_NAME}}:{{.OCM_COMPONENT_VERSION}} --repo {{.OCM_OUTPUT_DIR}} + - echo "\n--- Component Resources ---" + - ocm get resources -o wide {{.OCM_COMPONENT_NAME}}:{{.OCM_COMPONENT_VERSION}} --repo {{.OCM_OUTPUT_DIR}} + vars: + OCM_COMPONENT_VERSION: '{{.CLI_ARGS}}' + + test:build-image: + desc: "Builds the docker image for local testing. Usage: task test:build-image TAG=v-local-test" + cmds: + - docker build -t {{.DOCKER_IMAGE}} . + + test:publish-image: + desc: "Publishes the docker image for local testing. Usage: task test:publish-image TAG=v-local-test" + cmds: + - docker push {{.DOCKER_IMAGE}} + + test:run: + desc: "Runs the locally built image in a docker container. Usage: task test:run TAG=v-local-test" + cmds: + - docker run --rm -p 3000:3000 {{.DOCKER_IMAGE}} + + test:run-from-ocm: + desc: "Extracts image reference from OCM component and runs it. Usage: task test:run-from-ocm -- " + cmds: + - | + IMAGE_REF=$(ocm get resources {{.OCM_COMPONENT_NAME}}:{{.OCM_COMPONENT_VERSION}} --repo {{.OCM_OUTPUT_DIR}} -o json | jq -r '.resources[0].access.imageReference') + echo "Running image from OCM component: $IMAGE_REF" + docker run --rm -p 3000:3000 $IMAGE_REF + vars: + OCM_COMPONENT_VERSION: '{{.CLI_ARGS}}' + + local:start-registry: + desc: "Starts a local Docker registry on localhost:5000" + cmds: + - docker run -d -p 5000:5000 --name registry --rm registry:2 + status: + - docker ps | grep -q registry + + local:stop-registry: + desc: "Stops the local Docker registry" + cmds: + - docker stop registry + ignore_error: true + + local:build-and-push: + desc: "Builds and pushes image to local registry. Usage: task local:build-and-push TAG=v0.0.1" + cmds: + - docker build -t {{.LOCAL_DOCKER_IMAGE}} . + - docker push {{.LOCAL_DOCKER_IMAGE}} + + local:build-ocm: + desc: "Builds OCM component with local registry reference. Usage: task local:build-ocm -- " + cmds: + - rm -rf {{.OCM_OUTPUT_DIR}} + - | + ocm add components --create --force --copy-resources --complete \ + --lookup {{.LOCAL_REGISTRY}} \ + --file {{.OCM_OUTPUT_DIR}} \ + {{.OCM_DESCRIPTOR}} -- \ + VERSION={{.OCM_COMPONENT_VERSION}} \ + COMPONENT_NAME={{.OCM_COMPONENT_NAME}} \ + PROVIDER={{.OCM_PROVIDER}} + vars: + OCM_COMPONENT_VERSION: '{{.CLI_ARGS}}' + env: + REGISTRY: "{{.LOCAL_REGISTRY}}" + + # This is full workflow to create local registry, build, push, create OCM and run application locally. + + local:test-full-flow: + desc: "Full local test: start registry, build, push, create OCM, run. Usage: task local:test-full-flow TAG=v0.0.1" + cmds: + - task: local:start-registry + - task: local:build-and-push + - task: local:build-ocm + vars: + CLI_ARGS: "{{.TAG}}" + - task: test:inspect-ocm + vars: + CLI_ARGS: "{{.TAG}}" + - task: test:run-from-ocm + vars: + CLI_ARGS: "{{.TAG}}" \ No newline at end of file diff --git a/ocm/component-descriptor-local.yaml b/ocm/component-descriptor-local.yaml new file mode 100644 index 00000000..6dab1c6f --- /dev/null +++ b/ocm/component-descriptor-local.yaml @@ -0,0 +1,13 @@ +name: ${COMPONENT_NAME} +version: ${VERSION} +provider: + name: ${PROVIDER} +sources: [] +componentReferences: [] +resources: + - name: mcp-ui-frontend-image + type: ociImage + version: ${VERSION} + access: + type: ociArtifact + imageReference: localhost:5000/mcp-ui-frontend:${VERSION} diff --git a/ocm/component-descriptor.yaml b/ocm/component-descriptor.yaml new file mode 100644 index 00000000..59c09165 --- /dev/null +++ b/ocm/component-descriptor.yaml @@ -0,0 +1,13 @@ +name: ${COMPONENT_NAME} +version: ${VERSION} +provider: + name: ${PROVIDER} +sources: [] +componentReferences: [] +resources: + - name: mcp-ui-frontend-image + type: ociImage + version: ${VERSION} + access: + type: ociArtifact + imageReference: ghcr.io/openmcp-project/mcp-ui-frontend:${VERSION} \ No newline at end of file From bd7439b3418f3c9d9a9b217185227389e2a4735c Mon Sep 17 00:00:00 2001 From: Hubert Date: Mon, 20 Oct 2025 12:25:33 +0200 Subject: [PATCH 2/4] local descriptor fix --- Taskfile.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 6076d328..1646fd0c 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -19,6 +19,7 @@ vars: OCM_TARGET_REPO: '{{.OCM_TARGET_REPO | default (print .REGISTRY "/components") }}' OCM_OUTPUT_DIR: "{{.ROOT_DIR}}/.ctf" OCM_DESCRIPTOR: "{{.ROOT_DIR}}/ocm/component-descriptor.yaml" + OCM_DESCRIPTOR_LOCAL: "{{.ROOT_DIR}}/ocm/component-descriptor-local.yaml" tasks: default: @@ -115,14 +116,12 @@ tasks: ocm add components --create --force --copy-resources --complete \ --lookup {{.LOCAL_REGISTRY}} \ --file {{.OCM_OUTPUT_DIR}} \ - {{.OCM_DESCRIPTOR}} -- \ + {{.OCM_DESCRIPTOR_LOCAL}} -- \ VERSION={{.OCM_COMPONENT_VERSION}} \ COMPONENT_NAME={{.OCM_COMPONENT_NAME}} \ PROVIDER={{.OCM_PROVIDER}} vars: OCM_COMPONENT_VERSION: '{{.CLI_ARGS}}' - env: - REGISTRY: "{{.LOCAL_REGISTRY}}" # This is full workflow to create local registry, build, push, create OCM and run application locally. From a53fb56e917fc7896e9bdb9519d9f00c3b57700b Mon Sep 17 00:00:00 2001 From: Hubert Date: Mon, 20 Oct 2025 13:08:43 +0200 Subject: [PATCH 3/4] fixing config for local docker and tags (was working only first time) --- Taskfile.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 1646fd0c..e688793a 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -83,9 +83,9 @@ tasks: desc: "Extracts image reference from OCM component and runs it. Usage: task test:run-from-ocm -- " cmds: - | - IMAGE_REF=$(ocm get resources {{.OCM_COMPONENT_NAME}}:{{.OCM_COMPONENT_VERSION}} --repo {{.OCM_OUTPUT_DIR}} -o json | jq -r '.resources[0].access.imageReference') + IMAGE_REF=$(ocm get resources {{.OCM_COMPONENT_NAME}}:{{.OCM_COMPONENT_VERSION}} --repo {{.OCM_OUTPUT_DIR}} -o json | jq -r '.items[0].element.access.imageReference') echo "Running image from OCM component: $IMAGE_REF" - docker run --rm -p 3000:3000 $IMAGE_REF + docker run --rm -p 5173:5173 --env-file {{.ROOT_DIR}}/.env $IMAGE_REF vars: OCM_COMPONENT_VERSION: '{{.CLI_ARGS}}' @@ -105,16 +105,17 @@ tasks: local:build-and-push: desc: "Builds and pushes image to local registry. Usage: task local:build-and-push TAG=v0.0.1" cmds: - - docker build -t {{.LOCAL_DOCKER_IMAGE}} . - - docker push {{.LOCAL_DOCKER_IMAGE}} + - docker build -t localhost:5000/mcp-ui-frontend:{{.TAG}} . + - docker push localhost:5000/mcp-ui-frontend:{{.TAG}} + vars: + TAG: '{{.TAG | default "latest"}}' local:build-ocm: - desc: "Builds OCM component with local registry reference. Usage: task local:build-ocm -- " + desc: "Builds OCM component with local registry reference (uses --skip-digest-generation for local testing). Usage: task local:build-ocm -- " cmds: - rm -rf {{.OCM_OUTPUT_DIR}} - | - ocm add components --create --force --copy-resources --complete \ - --lookup {{.LOCAL_REGISTRY}} \ + ocm add components --create --force --skip-digest-generation \ --file {{.OCM_OUTPUT_DIR}} \ {{.OCM_DESCRIPTOR_LOCAL}} -- \ VERSION={{.OCM_COMPONENT_VERSION}} \ @@ -130,6 +131,8 @@ tasks: cmds: - task: local:start-registry - task: local:build-and-push + vars: + TAG: "{{.TAG}}" - task: local:build-ocm vars: CLI_ARGS: "{{.TAG}}" From a8f7e95b296bc4384953a620269db12dbcc5e997 Mon Sep 17 00:00:00 2001 From: Hubert Date: Wed, 22 Oct 2025 15:20:38 +0200 Subject: [PATCH 4/4] PR changes --- Dockerfile | 1 - Taskfile.yml | 100 ++-------------------------- ocm/component-descriptor-local.yaml | 13 ---- 3 files changed, 5 insertions(+), 109 deletions(-) delete mode 100644 ocm/component-descriptor-local.yaml diff --git a/Dockerfile b/Dockerfile index a5c104f5..d4544f83 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,6 @@ RUN npm ci # Build ENV NODE_ENV=production -ENV NODE_OPTIONS=--max-old-space-size=4096 COPY . . RUN npm run build diff --git a/Taskfile.yml b/Taskfile.yml index e688793a..97fb7e37 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -2,16 +2,11 @@ version: "3" vars: # Variables for Docker image - REGISTRY: ghcr.io/openmcp-project + REGISTRY: {{.REGISTRY | default (print "ghcr.io/openmcp-project") }} IMAGE_NAME: mcp-ui-frontend IMAGE_TAG: '{{.TAG | default "latest"}}' DOCKER_IMAGE: "{{.REGISTRY}}/{{.IMAGE_NAME}}:{{.IMAGE_TAG}}" - # Variables for local testing - LOCAL_REGISTRY: localhost:5000 - LOCAL_IMAGE_NAME: mcp-ui-frontend - LOCAL_DOCKER_IMAGE: "{{.LOCAL_REGISTRY}}/{{.LOCAL_IMAGE_NAME}}:{{.IMAGE_TAG}}" - # Variables for OCM component OCM_COMPONENT_NAME: github.com/openmcp-project/ui OCM_COMPONENT_VERSION: '{{.OCM_COMPONENT_VERSION | default .IMAGE_TAG}}' @@ -19,7 +14,6 @@ vars: OCM_TARGET_REPO: '{{.OCM_TARGET_REPO | default (print .REGISTRY "/components") }}' OCM_OUTPUT_DIR: "{{.ROOT_DIR}}/.ctf" OCM_DESCRIPTOR: "{{.ROOT_DIR}}/ocm/component-descriptor.yaml" - OCM_DESCRIPTOR_LOCAL: "{{.ROOT_DIR}}/ocm/component-descriptor-local.yaml" tasks: default: @@ -32,8 +26,7 @@ tasks: cmds: - rm -rf {{.OCM_OUTPUT_DIR}} - | - ocm add components --create --force --copy-resources \ - --complete \ + ocm add components --create \ --lookup {{.OCM_TARGET_REPO}} \ --file {{.OCM_OUTPUT_DIR}} \ {{.OCM_DESCRIPTOR}} -- \ @@ -48,97 +41,14 @@ tasks: cmds: - | ocm transfer ctf \ - --copy-resources \ - --enforce --overwrite \ {{.OCM_OUTPUT_DIR}} {{.OCM_TARGET_REPO}} - # Those tasks are only for local testing purposes - - test:inspect-ocm: - desc: "Inspects the locally built OCM component. Usage: task test:inspect-ocm -- " - cmds: - - echo "--- Component Details ---" - - ocm get component -o yaml {{.OCM_COMPONENT_NAME}}:{{.OCM_COMPONENT_VERSION}} --repo {{.OCM_OUTPUT_DIR}} - - echo "\n--- Component Resources ---" - - ocm get resources -o wide {{.OCM_COMPONENT_NAME}}:{{.OCM_COMPONENT_VERSION}} --repo {{.OCM_OUTPUT_DIR}} - vars: - OCM_COMPONENT_VERSION: '{{.CLI_ARGS}}' - - test:build-image: + build:image:local: desc: "Builds the docker image for local testing. Usage: task test:build-image TAG=v-local-test" cmds: - docker build -t {{.DOCKER_IMAGE}} . - test:publish-image: + publish:image:local: desc: "Publishes the docker image for local testing. Usage: task test:publish-image TAG=v-local-test" cmds: - - docker push {{.DOCKER_IMAGE}} - - test:run: - desc: "Runs the locally built image in a docker container. Usage: task test:run TAG=v-local-test" - cmds: - - docker run --rm -p 3000:3000 {{.DOCKER_IMAGE}} - - test:run-from-ocm: - desc: "Extracts image reference from OCM component and runs it. Usage: task test:run-from-ocm -- " - cmds: - - | - IMAGE_REF=$(ocm get resources {{.OCM_COMPONENT_NAME}}:{{.OCM_COMPONENT_VERSION}} --repo {{.OCM_OUTPUT_DIR}} -o json | jq -r '.items[0].element.access.imageReference') - echo "Running image from OCM component: $IMAGE_REF" - docker run --rm -p 5173:5173 --env-file {{.ROOT_DIR}}/.env $IMAGE_REF - vars: - OCM_COMPONENT_VERSION: '{{.CLI_ARGS}}' - - local:start-registry: - desc: "Starts a local Docker registry on localhost:5000" - cmds: - - docker run -d -p 5000:5000 --name registry --rm registry:2 - status: - - docker ps | grep -q registry - - local:stop-registry: - desc: "Stops the local Docker registry" - cmds: - - docker stop registry - ignore_error: true - - local:build-and-push: - desc: "Builds and pushes image to local registry. Usage: task local:build-and-push TAG=v0.0.1" - cmds: - - docker build -t localhost:5000/mcp-ui-frontend:{{.TAG}} . - - docker push localhost:5000/mcp-ui-frontend:{{.TAG}} - vars: - TAG: '{{.TAG | default "latest"}}' - - local:build-ocm: - desc: "Builds OCM component with local registry reference (uses --skip-digest-generation for local testing). Usage: task local:build-ocm -- " - cmds: - - rm -rf {{.OCM_OUTPUT_DIR}} - - | - ocm add components --create --force --skip-digest-generation \ - --file {{.OCM_OUTPUT_DIR}} \ - {{.OCM_DESCRIPTOR_LOCAL}} -- \ - VERSION={{.OCM_COMPONENT_VERSION}} \ - COMPONENT_NAME={{.OCM_COMPONENT_NAME}} \ - PROVIDER={{.OCM_PROVIDER}} - vars: - OCM_COMPONENT_VERSION: '{{.CLI_ARGS}}' - - # This is full workflow to create local registry, build, push, create OCM and run application locally. - - local:test-full-flow: - desc: "Full local test: start registry, build, push, create OCM, run. Usage: task local:test-full-flow TAG=v0.0.1" - cmds: - - task: local:start-registry - - task: local:build-and-push - vars: - TAG: "{{.TAG}}" - - task: local:build-ocm - vars: - CLI_ARGS: "{{.TAG}}" - - task: test:inspect-ocm - vars: - CLI_ARGS: "{{.TAG}}" - - task: test:run-from-ocm - vars: - CLI_ARGS: "{{.TAG}}" \ No newline at end of file + - docker push {{.DOCKER_IMAGE}} \ No newline at end of file diff --git a/ocm/component-descriptor-local.yaml b/ocm/component-descriptor-local.yaml deleted file mode 100644 index 6dab1c6f..00000000 --- a/ocm/component-descriptor-local.yaml +++ /dev/null @@ -1,13 +0,0 @@ -name: ${COMPONENT_NAME} -version: ${VERSION} -provider: - name: ${PROVIDER} -sources: [] -componentReferences: [] -resources: - - name: mcp-ui-frontend-image - type: ociImage - version: ${VERSION} - access: - type: ociArtifact - imageReference: localhost:5000/mcp-ui-frontend:${VERSION}