From 5c980889ece9f9b469ee0fe8ec3f7f782a9fcfb5 Mon Sep 17 00:00:00 2001 From: MoritzWeber Date: Thu, 4 May 2023 17:11:03 +0200 Subject: [PATCH 1/2] fix: Add support for pure::variants version != 5.x.x Resolves #139 --- .gitignore | 4 ++-- Makefile | 18 ++++++++++++++++- ci-templates/gitlab/image-builder.yml | 4 +++- docs/docs/capella/pure-variants.md | 4 +++- pure-variants/Dockerfile | 14 ++++++++++--- pure-variants/setup_workspace_purevariants.py | 20 ++++++++++++++++++- .../{updateSite => versions/6.0.0}/.gitkeep | 0 remote/Dockerfile | 1 + 8 files changed, 56 insertions(+), 9 deletions(-) rename pure-variants/{updateSite => versions/6.0.0}/.gitkeep (100%) diff --git a/.gitignore b/.gitignore index 70870864..6a1f26fa 100644 --- a/.gitignore +++ b/.gitignore @@ -26,8 +26,8 @@ ease/extensions/*/* !ease/extensions/*/.gitkeep # Pure::variants -pure-variants/updateSite/* -!pure-variants/updateSite/.gitkeep +pure-variants/versions/*/* +!pure-variants/versions/*/.gitkeep pure-variants/dependencies/* !pure-variants/dependencies/.gitkeep diff --git a/Makefile b/Makefile index 37b85d68..1ae956fc 100644 --- a/Makefile +++ b/Makefile @@ -73,6 +73,8 @@ export CAPELLA_VERSIONS ?= 5.0.0 5.2.0 6.0.0 # Capella version used to run containers export CAPELLA_VERSION ?= 6.0.0 +AUTOSTART_CAPELLA ?= 1 + # Comma-separated list of dropins to download & add, doesn't affect copied & mounted dropins # See available options in documentation: https://dsd-dbs.github.io/capella-dockerimages/capella/base/#optional-customisation-of-the-capella-client CAPELLA_DROPINS ?= CapellaXHTMLDocGen,DiagramStyler,PVMT,Filtering,Requirements,SubsystemTransition,TextualEditor @@ -84,6 +86,8 @@ export DOCKER_TAG_SCHEMA ?= $$CAPELLA_VERSION-$$CAPELLA_DOCKERIMAGES_REVISION export CAPELLA_DOCKERIMAGES_REVISION ?= latest export JUPYTER_NOTEBOOK_REVISION ?= python-3.11 +PURE_VARIANTS_VERSION ?= 6.0.0 + # UID which is used for the techuser in the Docker images export TECHUSER_UID = 1004370000 @@ -206,7 +210,12 @@ t4c/client/remote: t4c/client/base t4c/client/remote/pure-variants: SHELL=./capella_loop.sh t4c/client/remote/pure-variants: t4c/client/remote - docker build $(DOCKER_BUILD_FLAGS) -t $(DOCKER_PREFIX)$@:$$DOCKER_TAG --build-arg BUILD_TYPE=$(PURE_VARIANTS_BUILD_TYPE) --build-arg BASE_IMAGE=$(DOCKER_PREFIX)$<:$$DOCKER_TAG pure-variants + docker build $(DOCKER_BUILD_FLAGS) \ + -t $(DOCKER_PREFIX)$@:$$DOCKER_TAG \ + --build-arg BUILD_TYPE=$(PURE_VARIANTS_BUILD_TYPE) \ + --build-arg BASE_IMAGE=$(DOCKER_PREFIX)$<:$$DOCKER_TAG \ + --build-arg PURE_VARIANTS_VERSION=$(PURE_VARIANTS_VERSION) \ + pure-variants $(MAKE) PUSH_IMAGES=$(PUSH_IMAGES) IMAGENAME=$@ .push capella/remote/pure-variants: SHELL=./capella_loop.sh @@ -317,12 +326,15 @@ run-t4c/client/remote/pure-variants: t4c/client/remote/pure-variants -e T4C_USERNAME=$(T4C_USERNAME) \ -e PURE_VARIANTS_LICENSE_SERVER=$(PURE_VARIANTS_LICENSE_SERVER) \ -v $$(pwd)/volumes/pure-variants:/inputs/pure-variants \ + -v $$(pwd)/volumes/workspace:/workspace \ + -e AUTOSTART_CAPELLA=$(AUTOSTART_CAPELLA) \ -p $(RDP_PORT):3389 \ -p $(FILESYSTEM_PORT):8000 \ -p $(METRICS_PORT):9118 \ --rm \ $(DOCKER_PREFIX)t4c/client/remote/pure-variants:$$(echo "$(DOCKER_TAG_SCHEMA)" | envsubst) + run-t4c/client/backup: t4c/client/backup docker run $(DOCKER_RUN_FLAGS) --rm -it \ -e GIT_REPO_URL="$(GIT_REPO_URL)" \ @@ -367,6 +379,10 @@ debug-t4c/client/backup: LOG_LEVEL=DEBUG debug-t4c/client/backup: DOCKER_RUN_FLAGS=-it --entrypoint="bash" -v $$(pwd)/backups/backup.py:/opt/capella/backup.py debug-t4c/client/backup: run-t4c/client/backup +debug-t4c/client/remote/pure-variants: AUTOSTART_CAPELLA=0 +debug-t4c/client/remote/pure-variants: DOCKER_RUN_FLAGS=-it --entrypoint="bash" +debug-t4c/client/remote/pure-variants: run-t4c/client/remote/pure-variants + t4c/server/server: SHELL=./capella_loop.sh t4c/server/server: $(MAKE) -C t4c/server PUSH_IMAGES=$(PUSH_IMAGES) CAPELLA_VERSION=$$CAPELLA_VERSION $@ diff --git a/ci-templates/gitlab/image-builder.yml b/ci-templates/gitlab/image-builder.yml index 1d4fcbcb..56735663 100644 --- a/ci-templates/gitlab/image-builder.yml +++ b/ci-templates/gitlab/image-builder.yml @@ -61,6 +61,7 @@ variables: description: "Python version for the jupyter notebook." DOCKER_BUILD_ARGS: "--no-cache" BUILD_ARCHITECTURE: amd64 + PURE_VARIANTS_VERSION: "6.0.0" default: image: $DOCKER_REGISTRY/base @@ -294,12 +295,13 @@ t4c/client/remote/pure-variants: - *prepare - *docker - mv ../../pure-variants/dependencies/* pure-variants/dependencies/ - - mv ../../pure-variants/updateSite/* pure-variants/updateSite/ + - mv ../../pure-variants/updateSite/* pure-variants/versions/${PURE_VARIANTS_VERSION:?} - | docker build $DOCKER_BUILD_ARGS \ -t $DOCKER_REGISTRY/t4c/client/remote/pure-variants:$DOCKER_TAG \ --build-arg BUILD_TYPE=offline \ --build-arg BASE_IMAGE=$BASE_IMAGE \ + --build-arg PURE_VARIANTS_VERSION="$PURE_VARIANTS_VERSION" \ pure-variants - *push diff --git a/docs/docs/capella/pure-variants.md b/docs/docs/capella/pure-variants.md index 97fa7af2..95496187 100644 --- a/docs/docs/capella/pure-variants.md +++ b/docs/docs/capella/pure-variants.md @@ -51,7 +51,8 @@ pure-variants/dependencies Please select: "pure::variants Archived Update Site with all Extensions" for Linux (Tux). -1. Place the zip-file into `pure-variants/updateSite`. +1. Place the zip-file into `pure-variants/versions/$PURE_VARIANTS_VERSION`. + `$PURE_VARIANTS_VERSION` is the sematic version of pure::variants, e.g. `6.0.0`. ### Build it manually with Docker @@ -60,6 +61,7 @@ pure-variants/dependencies ```zsh docker build -t t4c/client/remote/pure-variants \ --build-arg CAPELLA_VERSION=$CAPELLA_VERSION \ + --build-arg PURE_VARIANTS_VERSION=$PURE_VARIANTS_VERSION \ pure-variants ``` diff --git a/pure-variants/Dockerfile b/pure-variants/Dockerfile index 1d128039..f48d9215 100644 --- a/pure-variants/Dockerfile +++ b/pure-variants/Dockerfile @@ -19,20 +19,28 @@ ENV SHELL=/bin/bash USER root -COPY ./updateSite /tmp/updateSite +ARG PURE_VARIANTS_VERSION +ENV PURE_VARIANTS_VERSION=${PURE_VARIANTS_VERSION} + +COPY ./versions/${PURE_VARIANTS_VERSION} /tmp/updateSite RUN mkdir /tmp/pure-variants && \ unzip /tmp/updateSite/* -d /tmp/pure-variants && \ rm -rf /tmp/updateSite + COPY setup_workspace_purevariants.py /opt/setup/setup_workspace_purevariants.py +USER techuser RUN /opt/capella/capella \ -consoleLog \ -application org.eclipse.equinox.p2.director \ -noSplash \ -repository ${REPOSITORY} \ -repository file:///tmp/pure-variants \ - -installIU com.ps.consul.eclipse.purevariants.capella.feature.group,com.ps.consul.eclipse.purevariants.emf.feature.mapping.feature.group,com.ps.consul.eclipse.purevariants.de.enterprise.feature.group && \ + -installIU com.ps.consul.eclipse.purevariants.capella.feature.group,com.ps.consul.eclipse.purevariants.emf.feature.mapping.feature.group,com.ps.consul.eclipse.purevariants.de.enterprise.feature.group + +USER root +RUN chmod +x /opt/capella/plugins/com.ps.consul.eclipse.core.linux_*/server/bin/variantsd && \ + chmod +x /opt/capella/plugins/com.ps.consul.eclipse.core.linux_*/server/bin/finishInstallation.sh && \ rm -rf /tmp/pure-variants -RUN chown -R techuser /opt/capella/plugins USER techuser diff --git a/pure-variants/setup_workspace_purevariants.py b/pure-variants/setup_workspace_purevariants.py index 0e814373..02e5888c 100644 --- a/pure-variants/setup_workspace_purevariants.py +++ b/pure-variants/setup_workspace_purevariants.py @@ -35,11 +35,29 @@ def replace_config(path: pathlib.Path, key: str, value: str) -> None: path.write_text(file_content) +def extract_pure_variants_major_version(version: str) -> str: + version = os.environ["PURE_VARIANTS_VERSION"] + + pattern = r"[0-9]\.*[0-9]\.*[0-9]*" + if not re.match(pattern, version): + raise RuntimeError( + f"The value of $PURE_VARIANTS_VERSION doesn't match the pattern {pattern}" + ) + + return version.split(".")[0] + + def copy_license_file_to_right_location(): source = pathlib.Path("/inputs/pure-variants/license.lic") + if source.exists(): LOGGER.info("License file was found.") - destination = pathlib.Path("/home/techuser/pure-variants-5/de.license") + major_version = extract_pure_variants_major_version( + os.environ["PURE_VARIANTS_VERSION"] + ) + destination = pathlib.Path( + f"/home/techuser/pure-variants-{major_version}/de.license" + ) destination.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(source, destination) else: diff --git a/pure-variants/updateSite/.gitkeep b/pure-variants/versions/6.0.0/.gitkeep similarity index 100% rename from pure-variants/updateSite/.gitkeep rename to pure-variants/versions/6.0.0/.gitkeep diff --git a/remote/Dockerfile b/remote/Dockerfile index 9443031d..acb07626 100644 --- a/remote/Dockerfile +++ b/remote/Dockerfile @@ -55,6 +55,7 @@ RUN chmod 755 .startup.sh .config/openbox/autostart RUN pip install prometheus-client COPY metrics.py .metrics.py +RUN chown techuser /home/techuser/.metrics.py ENV AUTOSTART_CAPELLA=1 ENV RESTART_CAPELLA=1 From 141ee1b5ee1c6ac031b89914634af90ae15dcd0a Mon Sep 17 00:00:00 2001 From: MoritzWeber Date: Fri, 5 May 2023 17:19:23 +0200 Subject: [PATCH 2/2] fix: Add vfork launchMechanism for `pure::variants` Using this flag, `pure::variants` runs in a Docker container with build architecture aarch64 --- pure-variants/Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pure-variants/Dockerfile b/pure-variants/Dockerfile index f48d9215..19b5576a 100644 --- a/pure-variants/Dockerfile +++ b/pure-variants/Dockerfile @@ -43,4 +43,9 @@ RUN chmod +x /opt/capella/plugins/com.ps.consul.eclipse.core.linux_*/server/bin/ chmod +x /opt/capella/plugins/com.ps.consul.eclipse.core.linux_*/server/bin/finishInstallation.sh && \ rm -rf /tmp/pure-variants +# In some cases, the pure::variants server could not start with the error message: +# Cannot run program `...`, failed to exec spawn helper, exit value: 1 +# This fixes the error by switching to the vfork launch mechanism +RUN echo '-Djdk.lang.Process.launchMechanism=vfork' >> /opt/capella/capella.ini + USER techuser