Skip to content

Commit

Permalink
Merge pull request #141 from DSD-DBS/pv_fix
Browse files Browse the repository at this point in the history
Add support for pure::variants version != 5.x.x
  • Loading branch information
MoritzWeber0 authored May 9, 2023
2 parents a9c562d + 141ee1b commit e9e4efd
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)" \
Expand Down Expand Up @@ -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 $@
Expand Down
4 changes: 3 additions & 1 deletion ci-templates/gitlab/image-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion docs/docs/capella/pure-variants.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
```

Expand Down
19 changes: 16 additions & 3 deletions pure-variants/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,33 @@ 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

# 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
20 changes: 19 additions & 1 deletion pure-variants/setup_workspace_purevariants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions remote/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e9e4efd

Please sign in to comment.