This is an automated email from the ASF dual-hosted git repository. jbonofre pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/master by this push: new 45e86f6 Feature/optimize docker script and update docs (#1190) 45e86f6 is described below commit 45e86f6b3c03eaeacce1e83a19dc913875f9f059 Author: Antonio Musarra <antonio.musa...@gmail.com> AuthorDate: Thu Sep 17 11:00:43 2020 +0200 Feature/optimize docker script and update docs (#1190) --- assemblies/docker/README.md | 54 ++++++++++++++++++++++++++++++++++++--------- assemblies/docker/build.sh | 14 ++++++------ 2 files changed, 51 insertions(+), 17 deletions(-) diff --git a/assemblies/docker/README.md b/assemblies/docker/README.md index fbb2bf6..cccb6f8 100644 --- a/assemblies/docker/README.md +++ b/assemblies/docker/README.md @@ -33,31 +33,65 @@ On macOS, an easy way to install `buildx` is to install [Docker Desktop Edge](ht ## Build Images are based on the Docker official [AdoptOpenJDK 11 JRE Hotspot](https://hub.docker.com/_/adoptopenjdk?tab=tags&page=1&name=11-jre-hotspot) image. If you want to -build the Karaf image run: +build the Karaf image you have the following choices: -``` -sh build.sh +1. Create the docker image from a local distribution package +2. Create the docker image from an Apache Karaf archive, for example (apache-karaf-4.2.9.tar.gz) +3. Create the docker image from a specific version of Apache Karaf +4. Create the docker image from remote or local custom Apache Karaf distribution + +If you run `build.sh` without arguments then you could see how to usage this command. + +```bash +Usage: + build.sh --from-local-dist [--archive <archive>] [--image-name <image>] [--build-multi-platform <comma-separated platforms>] + build.sh --from-release --karaf-version <x.x.x> [--image-name <image>] [--build-multi-platform <comma-separated platforms>] + build.sh --help + + If the --image-name flag is not used the built image name will be 'karaf'. + Check the supported build platforms; you can verify with this command: docker buildx ls + The supported platforms (OS/Arch) depend on the build's base image, in this case [adoptopenjdk:11-jre-hotspot](https://hub.docker.com/_/adoptopenjdk?tab=tags&page=1&name=11-jre-hotspot). ``` -or +To create the docker image from local distribution) you can execute the command +below. Remember that before you can successfully run this command, you must build +the project (for example with the command `mvn clean install -DskipTests`). +For more info you can read: +[Building Apache Karaf](https://github.com/apache/karaf/blob/master/BUILDING.md#building-apache-karaf) +```bash +./build.sh --from-local-dist ``` -docker build -t karaf . + +For create the docker image from the local dist version but with the archive, +you can execute the below command. Remember that before you can successfully run +this command. + +```bash +./build.sh --from-local-dist --archive ~/home/amusarra/apache-karaf-4.2.9.tar.gz ``` -If you want to build the container for a specific version of Karaf -you can configure it with the `KARAF_VERSION` arg: +You can also specify the image name with the `--image-name` flag, for example +(replacing the version, image name, and targets as appropriate): +```bash +./build.sh --from-local-dist --archive ~/Downloads/apache-karaf-4.2.9.tar.gz --image-name myrepo/mykaraf:x.x.x ``` -docker build --build-arg KARAF_VERSION=4.2.0 -t "karaf:4.2.0" karaf + +If you want to build the docker image for a specific version of Karaf +you can run `build.sh` command in this way (replacing the version, image name, +and targets as appropriate): + +```bash +./build.sh --from-release --karaf-version 4.2.9 --image-name myrepo/mykaraf:x.x.x ``` If you want to build the container for a specific version of Karaf and specific version of the platform, and push the image to the Docker Hub repository, you can use this command (replacing the version, image name, and targets as appropriate): -``` -./build.sh --from-release --karaf-version 4.2.9 --image-name amusarra/karaf:4.2.9 \ +```bash +./build.sh --from-release --karaf-version 4.2.9 --image-name myrepo/mykaraf:x.x.x \ --build-multi-platform linux/arm64,linux/arm/v7,linux/amd64 ``` diff --git a/assemblies/docker/build.sh b/assemblies/docker/build.sh index 0277448..cb7b06d 100755 --- a/assemblies/docker/build.sh +++ b/assemblies/docker/build.sh @@ -26,8 +26,8 @@ Usage: build.sh --help If the --image-name flag is not used the built image name will be 'karaf'. - Check the supported build platforms; you can verify with this command: `docker buildx ls` - The supported platforms (OS/Arch) depend on the build's base image, in this case [`openjdk:8u212-jre-alpine`](https://hub.docker.com/_/openjdk?tab=tags&page=1&name=8u212-jre-alpine). + Check the supported build platforms; you can verify with this command: docker buildx ls + The supported platforms (OS/Arch) depend on the build's base image, in this case [adoptopenjdk:11-jre-hotspot](https://hub.docker.com/_/adoptopenjdk?tab=tags&page=1&name=11-jre-hotspot). HERE exit 1 @@ -86,12 +86,12 @@ if [ -n "${FROM_RELEASE}" ]; then [ -n "${KARAF_VERSION}" ] || usage - KARAF_BASE_URL="$(curl -s https://www.apache.org/dyn/closer.cgi\?preferred\=true)karaf/${KARAF_VERSION}/" + KARAF_BASE_URL="$(curl -s https://www.apache.org/dyn/closer.cgi\?preferred=true)karaf/${KARAF_VERSION}/" KARAF_DIST_FILE_NAME="apache-karaf-${KARAF_VERSION}.tar.gz" CURL_OUTPUT="${TMPDIR}/${KARAF_DIST_FILE_NAME}" echo "Downloading ${KARAF_DIST_FILE_NAME} from ${KARAF_BASE_URL}" - curl -s ${KARAF_BASE_URL}${KARAF_DIST_FILE_NAME} --output ${CURL_OUTPUT} + curl -s "${KARAF_BASE_URL}${KARAF_DIST_FILE_NAME}" --output "${CURL_OUTPUT}" KARAF_DIST="${CURL_OUTPUT}" @@ -100,7 +100,7 @@ elif [ -n "${FROM_LOCAL}" ]; then if [ -n "${ARCHIVE}" ]; then DIST_DIR=${ARCHIVE} else - DIST_DIR=../apache-karaf/target/apache-karaf-*.tar.gz + DIST_DIR="../apache-karaf/target/apache-karaf-*.tar.gz" fi KARAF_DIST=${TMPDIR}/apache-karaf.tar.gz echo "Using karaf dist: ${DIST_DIR}" @@ -114,7 +114,7 @@ fi if [ -n "${BUILD_MULTI_PLATFORM}" ]; then echo "Checking if buildx installed..." - VERSION_BUILD_X=`docker buildx version` > /dev/null 2>&1 + VERSION_BUILD_X=$(docker buildx version) > /dev/null 2>&1 if [ $? -eq 0 ]; then echo "Found buildx {${VERSION_BUILD_X}} on your docker system" @@ -125,7 +125,7 @@ if [ -n "${BUILD_MULTI_PLATFORM}" ]; then BUILD_X_PLATFORM="--platform ${BUILD_MULTI_PLATFORM}" else echo "Error: buildx not installed with your docker system" - exit -1 + exit 2 fi fi