From d29135467669d5f5c6c2cba290a5b7bfc35cd731 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 17 Oct 2022 14:09:35 +0200 Subject: [PATCH] Support the build of multiple and different docker images MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- Dockerfile | 3 ++- Makefile | 6 +++--- build-image.sh | 33 +++++++++++++++++++++++++++++++++ docker-compose.yml | 29 +++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 4 deletions(-) create mode 100755 build-image.sh diff --git a/Dockerfile b/Dockerfile index e772cea..fd92977 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Makefile b/Makefile index b972ac2..d181f73 100644 --- 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 index 0000000..d18125a --- /dev/null +++ b/build-image.sh @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index e27e772..62f8405 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 -- 2.34.1