Skip to content

Commit

Permalink
Merge pull request #136 from DSD-DBS/dropins
Browse files Browse the repository at this point in the history
Push images for different dropins sets
  • Loading branch information
MoritzWeber0 authored May 4, 2023
2 parents 59f3216 + 3820f06 commit a9c562d
Show file tree
Hide file tree
Showing 11 changed files with 300 additions and 27 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/deploy-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ name: Build & push images
on:
push:
pull_request:
branches: [main, staging]
branches: ["main"]

env:
registry: ghcr.io/dsd-dbs/capella-dockerimages/
images: capella/remote capella/readonly capella/ease capella/cli
images: capella/base capella/cli capella/remote capella/ease capella/readonly

jobs:
deploy-docker-images:
Expand All @@ -21,7 +21,12 @@ jobs:
- "5.2.0"
- "6.0.0"
- "6.1.0"
name: Capella ${{ matrix.capella_version }}
dropins:
- name: "without" # without dropins
dropins: ""
- name: "selected"
dropins: "CapellaXHTMLDocGen,DiagramStyler,PVMT,Filtering,Requirements,SubsystemTransition" # selected set of dropins
name: Capella ${{ matrix.capella_version }} with ${{ matrix.dropins.name }} dropins
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -45,20 +50,22 @@ jobs:
- name: Build
run: >
make ${{ env.images }}
CAPELLA_VERSIONS=${{ matrix.capella_version }}
DOCKER_PREFIX=${{ env.registry }}
CAPELLA_DOCKERIMAGES_REVISION=${{ steps.tag.outputs.branch }}
CAPELLA_VERSIONS="${{ matrix.capella_version }}"
DOCKER_PREFIX="${{ env.registry }}"
CAPELLA_DOCKERIMAGES_REVISION="${{ steps.tag.outputs.branch }}"
CAPELLA_DROPINS="${{ matrix.dropins.dropins }}"
DOCKER_TAG_SCHEMA=${{ matrix.capella_version }}-${{ matrix.dropins.name }}-dropins-${{ steps.tag.outputs.branch }}
DOCKER_BUILD_FLAGS="--label git-short-sha=${{ steps.tag.outputs.sha }}"
- name: Install test dependencies
run: |
pip install .
- name: Run pytest
run: >
DOCKER_PREFIX=${{ env.registry }}
DOCKER_TAG=${{ matrix.capella_version }}-${{ steps.tag.outputs.branch }}
DOCKER_PREFIX="${{ env.registry }}"
DOCKER_TAG="${{ matrix.capella_version }}-${{ matrix.dropins.name }}-dropins-${{ steps.tag.outputs.branch }}"
pytest -m "not (t4c_server or t4c)" tests
- name: Push
run: |
for image in ${{ env.images }}
do docker push ${{ env.registry }}$image:${{ matrix.capella_version }}-${{ steps.tag.outputs.branch }}
do docker push "${{ env.registry }}$image:${{ matrix.capella_version }}-${{ matrix.dropins.name }}-dropins-${{ steps.tag.outputs.branch }}"
done
36 changes: 23 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,14 @@ METRICS_PORT ?= 9118
export CAPELLA_VERSIONS ?= 5.0.0 5.2.0 6.0.0

# Capella version used to run containers
CAPELLA_VERSION ?= 6.0.0
export CAPELLA_VERSION ?= 6.0.0

# Only used when "capella_loop.sh" is NOT used
export DOCKER_TAG=$(CAPELLA_VERSION)-$(CAPELLA_DOCKERIMAGES_REVISION)
# 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

# Only use when "capella_loop.sh" is NOT used
export DOCKER_TAG_SCHEMA ?= $$CAPELLA_VERSION-$$CAPELLA_DOCKERIMAGES_REVISION

# Should be 'latest', the branch name, the commit hash or a Git tag name
export CAPELLA_DOCKERIMAGES_REVISION ?= latest
Expand Down Expand Up @@ -110,8 +114,6 @@ DOCKER_REGISTRY ?= localhost:12345
# Log level when running Docker containers
LOG_LEVEL ?= DEBUG

GIT_SHA = $(shell git rev-parse --short HEAD)

# If this option is set to 1, all tests that require a running t4c server
# will be executed. To run these tests, you need a Makefile in
# t4c/server with a target t4c/server/server that builds the t4c server
Expand Down Expand Up @@ -150,10 +152,12 @@ all: \
t4c/client/backup \
t4c/client/exporter

base: SHELL=/bin/bash
base:
docker build $(DOCKER_BUILD_FLAGS) --build-arg UID=$(TECHUSER_UID) -t $(DOCKER_PREFIX)$@:$(CAPELLA_DOCKERIMAGES_REVISION) base
$(MAKE) PUSH_IMAGES=$(PUSH_IMAGES) DOCKER_TAG=$(CAPELLA_DOCKERIMAGES_REVISION) IMAGENAME=$@ .push

base: SHELL=/bin/bash
jupyter-notebook: base
docker build $(DOCKER_BUILD_FLAGS) -t $(DOCKER_PREFIX)$@:$(JUPYTER_NOTEBOOK_REVISION) jupyter-notebook
$(MAKE) PUSH_IMAGES=$(PUSH_IMAGES) DOCKER_TAG=$(JUPYTER_NOTEBOOK_REVISION) IMAGENAME=$@ .push
Expand All @@ -167,6 +171,7 @@ capella/base: base
--build-arg BASE_IMAGE=$(DOCKER_PREFIX)$<:$(CAPELLA_DOCKERIMAGES_REVISION) \
--build-arg BUILD_TYPE=$(CAPELLA_BUILD_TYPE) \
--build-arg CAPELLA_VERSION=$$CAPELLA_VERSION \
--build-arg "CAPELLA_DROPINS=$(CAPELLA_DROPINS)" \
--build-arg INSTALL_OLD_GTK_VERSION=$(INSTALL_OLD_GTK_VERSION) \
capella
rm capella/.dockerignore
Expand Down Expand Up @@ -239,11 +244,14 @@ t4c/client/exporter: t4c/client/base
docker build $(DOCKER_BUILD_FLAGS) -t $(DOCKER_PREFIX)$@:$$DOCKER_TAG --build-arg BUILD_ARCHITECTURE=$(BUILD_ARCHITECTURE) --build-arg BASE_IMAGE=$(DOCKER_PREFIX)$<:$$DOCKER_TAG --build-arg CAPELLA_VERSION=$$CAPELLA_VERSION exporter
$(MAKE) PUSH_IMAGES=$(PUSH_IMAGES) IMAGENAME=$@ .push


capella/builder:
docker build $(DOCKER_BUILD_FLAGS) -t $(DOCKER_PREFIX)$@:$(CAPELLA_DOCKERIMAGES_REVISION) builder
docker run -it -e CAPELLA_VERSION=$(CAPELLA_VERSION) -v $$(pwd)/builder/output/$(CAPELLA_VERSION):/output -v $$(pwd)/builder/m2_cache:/root/.m2/repository $(DOCKER_PREFIX)$@:$(CAPELLA_DOCKERIMAGES_REVISION)

run-capella/base: capella/base
docker run $(DOCKER_RUN_FLAGS) \
$(DOCKER_PREFIX)capella/base:$$(echo "$(DOCKER_TAG_SCHEMA)" | envsubst)

run-capella/readonly: capella/readonly
docker run $(DOCKER_RUN_FLAGS) \
-p $(RDP_PORT):3389 \
Expand All @@ -254,7 +262,7 @@ run-capella/readonly: capella/readonly
-e GIT_DEPTH=$(GIT_REPO_DEPTH) \
-e GIT_USERNAME="" \
-e GIT_PASSWORD="" \
$(DOCKER_PREFIX)capella/readonly:$(DOCKER_TAG)
$(DOCKER_PREFIX)capella/readonly:$$(echo "$(DOCKER_TAG_SCHEMA)" | envsubst)

run-capella/readonly-debug: capella/readonly
docker run $(DOCKER_RUN_FLAGS) \
Expand All @@ -271,7 +279,7 @@ run-capella/readonly-debug: capella/readonly
-e GIT_USERNAME="$(GIT_USERNAME)" \
-e GIT_PASSWORD="$(GIT_PASSWORD)" \
--entrypoint bash \
$(DOCKER_PREFIX)capella/readonly:$(DOCKER_TAG)
$(DOCKER_PREFIX)capella/readonly:$$(echo "$(DOCKER_TAG_SCHEMA)" | envsubst)

run-t4c/client/remote-legacy: t4c/client/remote
docker rm /t4c-client-remote || true
Expand All @@ -286,7 +294,7 @@ run-t4c/client/remote-legacy: t4c/client/remote
-p $(FILESYSTEM_PORT):8000 \
-p $(METRICS_PORT):9118 \
--name t4c-client-remote-legacy \
$(DOCKER_PREFIX)t4c/client/remote:$(DOCKER_TAG)
$(DOCKER_PREFIX)t4c/client/remote:$$(echo "$(DOCKER_TAG_SCHEMA)" | envsubst)

run-t4c/client/remote-json: t4c/client/remote
docker rm /t4c-client-remote-json || true
Expand All @@ -299,7 +307,7 @@ run-t4c/client/remote-json: t4c/client/remote
-p $(FILESYSTEM_PORT):8000 \
-p $(METRICS_PORT):9118 \
--name t4c-client-remote-json \
$(DOCKER_PREFIX)t4c/client/remote:$(DOCKER_TAG)
$(DOCKER_PREFIX)t4c/client/remote:$$(echo "$(DOCKER_TAG_SCHEMA)" | envsubst)

run-t4c/client/remote/pure-variants: t4c/client/remote/pure-variants
docker run $(DOCKER_RUN_FLAGS) \
Expand All @@ -313,7 +321,7 @@ run-t4c/client/remote/pure-variants: t4c/client/remote/pure-variants
-p $(FILESYSTEM_PORT):8000 \
-p $(METRICS_PORT):9118 \
--rm \
$(DOCKER_PREFIX)t4c/client/remote/pure-variants:$(DOCKER_TAG)
$(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 \
Expand All @@ -332,7 +340,7 @@ run-t4c/client/backup: t4c/client/backup
-e HTTP_PORT="$(HTTP_PORT)" \
-e LOG_LEVEL="$(LOG_LEVEL)" \
-e CONNECTION_TYPE="$(CONNECTION_TYPE)" \
$(DOCKER_PREFIX)t4c/client/backup:$(DOCKER_TAG)
$(DOCKER_PREFIX)t4c/client/backup:$$(echo "$(DOCKER_TAG_SCHEMA)" | envsubst)

run-t4c/client/exporter: t4c/client/exporter
docker run $(DOCKER_RUN_FLAGS) \
Expand All @@ -350,8 +358,10 @@ run-t4c/client/exporter: t4c/client/exporter
-e HTTP_LOGIN="${HTTP_LOGIN}" \
-e HTTP_PASSWORD="${HTTP_PASSWORD}" \
-e LOG_LEVEL="$(LOG_LEVEL)" \
$(DOCKER_PREFIX)t4c/client/exporter:$(DOCKER_TAG)
$(DOCKER_PREFIX)t4c/client/exporter:$(echo "$(DOCKER_TAG_SCHEMA)" | envsubst)

debug-capella/base: DOCKER_RUN_FLAGS=-it --entrypoint="bash"
debug-capella/base: run-capella/base

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
Expand Down
10 changes: 10 additions & 0 deletions capella/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,17 @@ RUN chmod +x capella/capella && \
chown -R techuser /opt/capella

# Install Dropins for Capella
USER techuser

COPY ./versions/${CAPELLA_VERSION}/dropins /opt/capella/dropins
ARG CAPELLA_DROPINS=""
COPY install_dropins.py /opt/install_dropins.py
COPY ./versions/${CAPELLA_VERSION}/dropins.yml /opt/dropins.yml
RUN echo '-Dorg.eclipse.equinox.p2.transport.ecf.retry=15' >> /opt/capella/capella.ini
RUN echo '-Dorg.eclipse.ecf.provider.filetransfer.retrieve.readTimeout=10000' >> /opt/capella/capella.ini
RUN pip install PyYAML && python install_dropins.py

USER root

# Eclipse settings
RUN mkdir -p /opt/capella/configuration/.settings; \
Expand Down
52 changes: 52 additions & 0 deletions capella/install_dropins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors
# SPDX-License-Identifier: Apache-2.0

import os
import pathlib
import subprocess
import typing as t

import yaml


def load_dropins() -> dict[str, t.Any]:
return yaml.safe_load(
pathlib.Path("/opt/dropins.yml").read_text(encoding="utf-8")
)["dropins"]


def extract_repositories_and_installIUs(dropins: dict[str, t.Any]) -> None:
for dropin_slug in os.getenv("CAPELLA_DROPINS", "").split(","):
if not dropin_slug:
continue

if not dropin_slug in dropins:
raise KeyError(
f"Dropin '{dropin_slug}' not found in list of supported dropins."
)

dropin = dropins[dropin_slug]

install_update_sites(dropin["eclipseRepository"], dropin["installIU"])


def install_update_sites(repository: str, install_ui: list[str]):
subprocess.run(
[
"/opt/capella/capella",
"-consoleLog",
"-application",
"org.eclipse.equinox.p2.director",
"-noSplash",
"-repository",
repository,
"-installIU",
",".join(install_ui),
],
check=True,
)


if __name__ == "__main__":
dropins = load_dropins()
extract_repositories_and_installIUs(dropins)
39 changes: 39 additions & 0 deletions capella/versions/5.0.0/dropins.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors
# SPDX-License-Identifier: Apache-2.0

dropins:
CapellaXHTMLDocGen:
github: "https://github.com/eclipse/capella-xhtml-docgen"
eclipseRepository: "https://download.eclipse.org/capella/addons/xhtmldocgen/updates/releases/5.0.0/"
installIU:
- "org.polarsys.capella.docgen.package.feature.feature.group"
DiagramStyler:
github: "https://github.com/eclipse/capella/wiki/PVMT"
eclipseRepository: "jar:https://artifactory.thalesdigital.io/ui/api/v1/download?repoKey=mvn-public&path=com%252Fthalesgroup%252Fmde%252Fcapella%252Fdiagramstyler%252Fcom.thalesgroup.mde.capella.diagramstyler.repository%252F50.3.1%252Fcom.thalesgroup.mde.capella.diagramstyler.repository-50.3.1.zip!/"
installIU:
- "com.thalesgroup.mde.capella.diagramstyler.feature.feature.group"
PVMT:
github: "https://github.com/eclipse/capella/wiki/PVMT"
eclipseRepository: "jar:https://artifactory.thalesdigital.io/ui/api/v1/download?repoKey=mvn-public&path=com%252Fthalesgroup%252Fvpd%252Fproperty%252Fcom.thalesgroup.vpd.property.repository%252F50.5.1%252Fcom.thalesgroup.vpd.property.repository-50.5.1.zip!/"
installIU:
- "com.thalesgroup.vpd.property.feature.feature.group"
Filtering:
github: "https://github.com/eclipse/capella-filtering"
eclipseRepository: "jar:https://download.eclipse.org/capella/addons/filtering/updates/releases/1.5.1/Filtering-updateSite-1.5.1.202104270742.zip!/"
installIU:
- "org.polarsys.capella.filtering.feature.feature.group"
Requirements:
github: "https://github.com/eclipse/capella-requirements-vp"
eclipseRepository: "jar:https://download.eclipse.org/capella/addons/requirements/updates/releases/0.12.3/Requirements-updateSite-0.12.3.202208111122.zip!/"
installIU:
- "org.polarsys.capella.vp.requirements.feature.feature.group"
SubsystemTransition:
github: "https://github.com/eclipse/capella-sss-transition"
eclipseRepository: "jar:https://download.eclipse.org/capella/addons/subsystemtransition/updates/releases/1.6.1/SubsystemTransition-updateSite-1.6.1.202302141252.zip!/"
installIU:
- "org.polarsys.capella.transition.system2subsystem.feature.feature.group"
TextualEditor:
github: "https://github.com/eclipse/capella-textual-editor"
eclipseRepository: "jar:https://download.eclipse.org/capella/addons/textualeditor/updates/releases/0.11.0/TextualEditor-updateSite-0.11.0.202208161352.zip!/"
installIU:
- "org.polarsys.capella.scenario.editor.feature.feature.group"
39 changes: 39 additions & 0 deletions capella/versions/5.2.0/dropins.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors
# SPDX-License-Identifier: Apache-2.0

dropins:
CapellaXHTMLDocGen:
github: "https://github.com/eclipse/capella-xhtml-docgen"
eclipseRepository: "https://download.eclipse.org/capella/addons/xhtmldocgen/updates/releases/5.2.0/"
installIU:
- "org.polarsys.capella.docgen.package.feature.feature.group"
DiagramStyler:
github: "https://github.com/eclipse/capella/wiki/PVMT"
eclipseRepository: "jar:https://artifactory.thalesdigital.io/ui/api/v1/download?repoKey=mvn-public&path=com%252Fthalesgroup%252Fmde%252Fcapella%252Fdiagramstyler%252Fcom.thalesgroup.mde.capella.diagramstyler.repository%252F50.3.1%252Fcom.thalesgroup.mde.capella.diagramstyler.repository-50.3.1.zip!/"
installIU:
- "com.thalesgroup.mde.capella.diagramstyler.feature.feature.group"
PVMT:
github: "https://github.com/eclipse/capella/wiki/PVMT"
eclipseRepository: "jar:https://artifactory.thalesdigital.io/ui/api/v1/download?repoKey=mvn-public&path=com%252Fthalesgroup%252Fvpd%252Fproperty%252Fcom.thalesgroup.vpd.property.repository%252F50.5.1%252Fcom.thalesgroup.vpd.property.repository-50.5.1.zip!/"
installIU:
- "com.thalesgroup.vpd.property.feature.feature.group"
Filtering:
github: "https://github.com/eclipse/capella-filtering"
eclipseRepository: "jar:https://download.eclipse.org/capella/addons/filtering/updates/releases/1.5.2/Filtering-updateSite-1.5.2.202111091404.zip!/"
installIU:
- "org.polarsys.capella.filtering.feature.feature.group"
Requirements:
github: "https://github.com/eclipse/capella-requirements-vp"
eclipseRepository: "jar:https://download.eclipse.org/capella/addons/requirements/updates/releases/0.12.3/Requirements-updateSite-0.12.3.202208111122.zip!/"
installIU:
- "org.polarsys.capella.vp.requirements.feature.feature.group"
SubsystemTransition:
github: "https://github.com/eclipse/capella-sss-transition"
eclipseRepository: "jar:https://download.eclipse.org/capella/addons/subsystemtransition/updates/releases/1.6.1/SubsystemTransition-updateSite-1.6.1.202302141252.zip!/"
installIU:
- "org.polarsys.capella.transition.system2subsystem.feature.feature.group"
TextualEditor:
github: "https://github.com/eclipse/capella-textual-editor"
eclipseRepository: "jar:https://download.eclipse.org/capella/addons/textualeditor/updates/releases/0.11.0/TextualEditor-updateSite-0.11.0.202208161352.zip!/"
installIU:
- "org.polarsys.capella.scenario.editor.feature.feature.group"
39 changes: 39 additions & 0 deletions capella/versions/6.0.0/dropins.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors
# SPDX-License-Identifier: Apache-2.0

dropins:
CapellaXHTMLDocGen:
github: "https://github.com/eclipse/capella-xhtml-docgen"
eclipseRepository: "https://download.eclipse.org/capella/addons/xhtmldocgen/updates/releases/6.0.0/"
installIU:
- "org.polarsys.capella.docgen.package.feature.feature.group"
DiagramStyler:
github: "https://github.com/eclipse/capella/wiki/PVMT"
eclipseRepository: "jar:https://artifactory.thalesdigital.io/ui/api/v1/download?repoKey=mvn-public&path=com%252Fthalesgroup%252Fmde%252Fcapella%252Fdiagramstyler%252Fcom.thalesgroup.mde.capella.diagramstyler.repository%252F60.3.1%252Fcom.thalesgroup.mde.capella.diagramstyler.repository-60.3.1.zip!/"
installIU:
- "com.thalesgroup.mde.capella.diagramstyler.feature.feature.group"
PVMT:
github: "https://github.com/eclipse/capella/wiki/PVMT"
eclipseRepository: "jar:https://artifactory.thalesdigital.io/ui/api/v1/download?repoKey=mvn-public&path=com%252Fthalesgroup%252Fvpd%252Fproperty%252Fcom.thalesgroup.vpd.property.repository%252F60.7.0%252Fcom.thalesgroup.vpd.property.repository-60.7.0.zip!/"
installIU:
- "com.thalesgroup.vpd.property.feature.feature.group"
Filtering:
github: "https://github.com/eclipse/capella-filtering"
eclipseRepository: "jar:https://download.eclipse.org/capella/addons/filtering/updates/releases/1.6.0/Filtering-updateSite-1.6.0.202206090715.zip!/"
installIU:
- "org.polarsys.capella.filtering.feature.feature.group"
Requirements:
github: "https://github.com/eclipse/capella-requirements-vp"
eclipseRepository: "jar:https://download.eclipse.org/capella/addons/requirements/updates/releases/0.13.1/Requirements-updateSite-0.13.1.202303011400.zip!/"
installIU:
- "org.polarsys.capella.vp.requirements.feature.feature.group"
SubsystemTransition:
github: "https://github.com/eclipse/capella-sss-transition"
eclipseRepository: "jar:https://download.eclipse.org/capella/addons/subsystemtransition/updates/releases/1.6.1/SubsystemTransition-updateSite-1.6.1.202302141252.zip!/"
installIU:
- "org.polarsys.capella.transition.system2subsystem.feature.feature.group"
TextualEditor:
github: "https://github.com/eclipse/capella-textual-editor"
eclipseRepository: "jar:https://download.eclipse.org/capella/addons/textualeditor/updates/releases/0.11.0/TextualEditor-updateSite-0.11.0.202208161352.zip!/"
installIU:
- "org.polarsys.capella.scenario.editor.feature.feature.group"
Loading

0 comments on commit a9c562d

Please sign in to comment.