From 375e59d57c9d5c954f6f02558483bc124b4d1e3c Mon Sep 17 00:00:00 2001
From: Rainer Kartmann <rainer.kartmann@kit.edu>
Date: Wed, 18 Oct 2023 19:19:52 +0200
Subject: [PATCH] Add dockerfiles, build docker images and test in docker
 containers

---
 .gitlab-ci.yml               | 82 ++++++++++++++++++++++++++++++++++++
 docker/armarx-workspace.json | 17 ++++++++
 docker/bionic                | 20 +++++++++
 docker/jammy                 | 20 +++++++++
 4 files changed, 139 insertions(+)
 create mode 100644 docker/armarx-workspace.json
 create mode 100644 docker/bionic
 create mode 100644 docker/jammy

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a371fca5..fe4bbaa3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,5 +1,7 @@
 stages:
   - build-and-test
+  - deploy
+  - post-deploy-test
 
 
 .build-and-test:
@@ -82,3 +84,83 @@ build-and-test-jammy:
   extends: .build-and-test
 
   image: git.h2t.iar.kit.edu:5050/sw/armarx/armarx-core:latest-jammy
+
+
+docker-bionic:
+  stage: deploy
+  needs: ["build-and-test-bionic"]
+  image:
+    name: gcr.io/kaniko-project/executor:v1.9.0-debug
+    entrypoint: [""]
+  script:
+    - /kaniko/executor
+      --context "${CI_PROJECT_DIR}"
+      --dockerfile "${CI_PROJECT_DIR}/docker/bionic"
+      --destination "${CI_REGISTRY_IMAGE}:latest-bionic"
+
+  rules:
+    - if: $CI_COMMIT_BRANCH == "master"
+
+
+docker-jammy:
+  stage: deploy
+  needs: ["build-and-test-jammy"]
+  image:
+    name: gcr.io/kaniko-project/executor:v1.9.0-debug
+    entrypoint: [""]
+  script:
+    - /kaniko/executor
+      --context "${CI_PROJECT_DIR}"
+      --dockerfile "${CI_PROJECT_DIR}/docker/jammy"
+      --destination "${CI_REGISTRY_IMAGE}:latest-jammy"
+
+  rules:
+    - if: $CI_COMMIT_BRANCH == "master"
+
+
+.test-docker-image-common:
+
+  before_script:
+    - source /axii/scripts/install_axii.sh
+    - _axii_auto_env_refresh
+
+  script:
+    - echo "ArmarX Workspace = '$ARMARX_WORKSPACE'"
+    - printenv
+
+    - axii workspace list-modules
+    - axii workspace list-modules --deps
+    - axii workspace info
+    - echo "ArmarXCore directory = '$ArmarXCore_DIR'"
+
+    - which armarx
+    - which armarx-package
+
+    - armarx switch docker_test --ice-host 127.0.0.1 --ice-port 10000 --ice-default-host 127.0.0.1 --mongo-host 127.0.0.1 --mongo-port 10001
+    - armarx profile
+    - armarx status || true
+
+    - cd $ArmarXGui_DIR
+    - ctest --output-on-failure .
+
+
+test-docker-image-bionic:
+  stage: post-deploy-test
+  needs: ["docker-bionic"]
+  extends: .test-docker-image-common
+
+  image: git.h2t.iar.kit.edu:5050/sw/armarx/armarx-gui:latest-bionic
+
+  rules:
+    - if: $CI_COMMIT_BRANCH == "master"
+
+
+test-docker-image-jammy:
+  stage: post-deploy-test
+  needs: ["docker-jammy"]
+  extends: .test-docker-image-common
+
+  image: git.h2t.iar.kit.edu:5050/sw/armarx/armarx-gui:latest-jammy
+
+  rules:
+    - if: $CI_COMMIT_BRANCH == "master"
diff --git a/docker/armarx-workspace.json b/docker/armarx-workspace.json
new file mode 100644
index 00000000..5bc215b0
--- /dev/null
+++ b/docker/armarx-workspace.json
@@ -0,0 +1,17 @@
+{
+  "modules": {
+    "tools/ccache/default": {},
+    "armarx/ArmarXGui": {}
+  },
+  "global": {
+    "prepare": {
+      "cmake": {
+        "definitions": {
+          "CMAKE_BUILD_TYPE": "RelWithDebInfo",
+          "CMAKE_C_COMPILER_LAUNCHER": "$CCACHE",
+          "CMAKE_CXX_COMPILER_LAUNCHER": "$CCACHE"
+        }
+      }
+    }
+  }
+}
diff --git a/docker/bionic b/docker/bionic
new file mode 100644
index 00000000..064bb197
--- /dev/null
+++ b/docker/bionic
@@ -0,0 +1,20 @@
+FROM git.h2t.iar.kit.edu:5050/sw/armarx/armarx-core:latest-bionic
+
+# Setup environment.
+SHELL ["/bin/bash", "-c"]
+
+# Setup apt environment.
+RUN apt-get -qq update
+
+# Setup repository in Docker.
+WORKDIR $ARMARX_WORKSPACE/armarx/ArmarXGui
+COPY --chmod=755 . .
+
+# Use workspace config.
+COPY docker/armarx-workspace.json $ARMARX_WORKSPACE/armarx-workspace.json
+
+# Run the upgrade.
+RUN axii workspace system --accept-apt-install
+# ToDo: Prevent this from updating the target itself.
+RUN axii workspace update --prefer-https
+RUN axii workspace upgrade
diff --git a/docker/jammy b/docker/jammy
new file mode 100644
index 00000000..0994e506
--- /dev/null
+++ b/docker/jammy
@@ -0,0 +1,20 @@
+FROM git.h2t.iar.kit.edu:5050/sw/armarx/armarx-core:latest-jammy
+
+# Setup environment.
+SHELL ["/bin/bash", "-c"]
+
+# Setup apt environment.
+RUN apt-get -qq update
+
+# Setup repository in Docker.
+WORKDIR $ARMARX_WORKSPACE/armarx/ArmarXGui
+COPY --chmod=755 . .
+
+# Use workspace config.
+COPY docker/armarx-workspace.json $ARMARX_WORKSPACE/armarx-workspace.json
+
+# Run the upgrade.
+RUN axii workspace system --accept-apt-install
+# ToDo: Prevent this from updating the target itself.
+RUN axii workspace update --prefer-https
+RUN axii workspace upgrade
-- 
GitLab