Support the build of multiple and different docker images
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 17 Oct 2022 12:09:35 +0000 (14:09 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 17 Oct 2022 12:09:35 +0000 (14:09 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
Dockerfile
Makefile
build-image.sh [new file with mode: 0755]
docker-compose.yml

index e772ceaa5d9d6e0346b97f8b0cefe7d12d151f54..fd929773639f9342c5418917ab6dc3d1ee7f6cf3 100644 (file)
@@ -156,7 +156,8 @@ RUN set -ex \
 ARG MBT_VERSION=1.2.18
 
 RUN set -ex \
-  && npm install -g mbt@${MBT_VERSION} \
+  && npm install -g --unsafe-perm mbt@${MBT_VERSION} \
+  && npm cache clean -g --force \
   # smoke test
   && mbt --version
 
index b972ac2eedfdf327926ad8afcb727caa80af2a48..d181f733dc43f60d726f6a4ecce9d391d9047973 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 PROJECT_NAME?=sap-e-mobility
-NAME:=mbt-docker
+NAME?=mbt-node16-java11-docker
 SUBMODULES_INIT?=false
 DOCKER_REGISTRY_USERNAME?=fraggle0
 DOCKER_REGISTRY_PASSWORD?=
@@ -19,10 +19,10 @@ ifeq '$(SUBMODULES_INIT)' 'true'
 endif
 
 $(NAME): $(submodules-init)
-       docker-compose -p $(PROJECT_NAME) up -d
+       docker-compose -p $(PROJECT_NAME) up -d $(NAME)
 
 $(NAME)-force: $(submodules-init)
-       docker-compose -p $(PROJECT_NAME) up -d --build --force-recreate
+       docker-compose -p $(PROJECT_NAME) up -d --build --force-recreate $(NAME)
 
 all: $(NAME)
 
diff --git a/build-image.sh b/build-image.sh
new file mode 100755 (executable)
index 0000000..d18125a
--- /dev/null
@@ -0,0 +1,33 @@
+#!/usr/bin/env sh
+
+images="mbt-node14-java11-docker mbt-node16-java11-docker mbt-node14-java17-docker mbt-node16-java17-docker"
+
+usage() {
+  echo "Usage: $0 [-n <${images// /|}|all>" 1>&2; exit 1;
+}
+
+all() {
+  for image in ${images}; do
+    make NAME=${image}
+  done
+}
+
+[ $# -eq 0 ] && usage
+while getopts "n:h" option; do
+  case "${option}" in
+    n)
+      name=${OPTARG}
+      if [[ ${name} == "all" ]]; then
+        all
+      elif [[ -z "${images##*$name*}" ]]; then
+        make NAME=${name}
+      else
+        usage
+        exit 1
+      fi
+      ;;
+    *|h)
+      usage
+      ;;
+  esac
+done
index e27e772992d3772f699d16893a866f5009f80803..62f840571c816d1faa1fbe30e3e724192b426421 100644 (file)
@@ -1,6 +1,35 @@
 version: '3.8'
 services:
+  # TODO: remove once xmake is configured to push all images
   mbt-docker:
     platform: linux/amd64
     build:
       dockerfile: Dockerfile
+  mbt-node16-java11-docker:
+    platform: linux/amd64
+    build:
+      args:
+        NODE_VERSION: 16.18.0
+        SAPMACHINE_VERSION: 11.0.16.1
+      dockerfile: Dockerfile
+  mbt-node14-java11-docker:
+    platform: linux/amd64
+    build:
+      args:
+        NODE_VERSION: 14.20.1
+        SAPMACHINE_VERSION: 11.0.16.1
+      dockerfile: Dockerfile
+  mbt-node16-java17-docker:
+    platform: linux/amd64
+    build:
+      args:
+        NODE_VERSION: 16.18.0
+        SAPMACHINE_VERSION: 17.0.4.1
+      dockerfile: Dockerfile
+  mbt-node14-java17-docker:
+    platform: linux/amd64
+    build:
+      args:
+        NODE_VERSION: 14.20.1
+        SAPMACHINE_VERSION: 17.0.4.1
+      dockerfile: Dockerfile