From 17e1c39d41b9ca55d7e147aa5941041680f45250 Mon Sep 17 00:00:00 2001 From: Elvis de Freitas Date: Mon, 20 Feb 2023 11:48:57 -0300 Subject: [PATCH 01/18] trying to create build modules --- Dockerfile.builder | 11 ++++++++ builder.bash | 68 +++++++++++++++++++++++++++++----------------- 2 files changed, 54 insertions(+), 25 deletions(-) create mode 100644 Dockerfile.builder diff --git a/Dockerfile.builder b/Dockerfile.builder new file mode 100644 index 000000000..f0978b0ed --- /dev/null +++ b/Dockerfile.builder @@ -0,0 +1,11 @@ +FROM docker.io/defreitas/tools_graalvm-22.3_java-19_debian-9:0.1.1 AS BUILDER +COPY ./ /app +WORKDIR /app +RUN ./gradlew clean build -Dquarkus.package.type=native -i &&\ + ./gradlew -Dquarkus.package.type=uber-jar -i -x check &&\ + cd build && ls -lha &&\ + mkdir -p ./artifacts/linux-amd64 && mkdir -p ./artifacts/jre &&\ + mv $(ls -p | grep -v / | grep dns-proxy-server) ./artifacts/linux-amd64 &&\ + mv $(ls | grep -E 'dns-proxy-server.*\.jar') ./artifacts/jre + +ENTRYPOYINT cat diff --git a/builder.bash b/builder.bash index c265fbb4d..193be42a1 100755 --- a/builder.bash +++ b/builder.bash @@ -29,14 +29,50 @@ copyFileFromService(){ docker cp "$id:$from" "$to" } +validateRelease(){ + echo "> validate release, version=${APP_VERSION}, git=$(git rev-parse $APP_VERSION 2>/dev/null)" + if git rev-parse "$APP_VERSION^{}" >/dev/null 2>&1; then + echo "> Tag already exists $APP_VERSION" + exit 3 + fi +} + case $1 in validate-release ) - echo "> validate release, version=${APP_VERSION}, git=$(git rev-parse $APP_VERSION 2>/dev/null)" - if git rev-parse "$APP_VERSION^{}" >/dev/null 2>&1; then - echo "> Tag already exists $APP_VERSION" - exit 3 - fi + validateRelease + ;; + + build-frontend ) + ./builder.bash validate-release || exit 0 + + echo "> Building frontend files..." + docker-compose build --progress=plain build-frontend + rm -rf ./src/main/resources/META-INF/resources/static + copyFileFromService build-frontend /static ./src/main/resources/META-INF/resources/static + + echo "> Build, test and generate the binaries" + mkdir -p "${REPO_DIR}/build" + + ;; + + build-backend ) + + OS=linux + ARCH=amd64 + SERVICE_NAME="build-${OS}-${ARCH}" + ARTIFACTS_DIR="${REPO_DIR}/build/artifacts" + + mkdir -p ${ARTIFACTS_DIR} + +# BIN_FILE="${REPO_DIR}/build/dns-proxy-server-${OS}-${ARCH}-${APP_VERSION}" +# TAR_FILE=${BIN_FILE}.tgz + + VERSION=${APP_VERSION} docker-compose build --progress=plain ${SERVICE_NAME} + copyFileFromService ${SERVICE_NAME} /app/build/artifacts ${ARTIFACTS_DIR} +# cd $REPO_DIR/build/ +# tar --exclude=*.tgz -czf $TAR_FILE $(basename ${BIN_FILE}) + ;; deploy ) @@ -44,29 +80,11 @@ case $1 in echo "> Deploy started , current branch=$CURRENT_BRANCH" ./builder.bash validate-release || exit 0 - if [ "$CURRENT_BRANCH" != "master" ]; then - echo "> refusing to go ahead outside the master branch" - exit 8 - fi - - echo "> Building frontend files..." - docker-compose build --progress=plain build-frontend - rm -rf ./src/main/resources/META-INF/resources/static - copyFileFromService build-frontend /static ./src/main/resources/META-INF/resources/static + ./builder.bash build-frontend - echo "> Build, test and generate the binaries" - mkdir -p "${REPO_DIR}/build" + ./builder.bash build-backend - OS=linux - ARCH=amd64 - SERVICE_NAME="build-${OS}-${ARCH}" - BIN_FILE="${REPO_DIR}/build/dns-proxy-server-${OS}-${ARCH}-${APP_VERSION}" - TAR_FILE=${BIN_FILE}.tgz - VERSION=${APP_VERSION} docker-compose build --progress=plain ${SERVICE_NAME} - copyFileFromService ${SERVICE_NAME} /app/dns-proxy-server ${BIN_FILE} - cd $REPO_DIR/build/ - tar --exclude=*.tgz -czf $TAR_FILE $(basename ${BIN_FILE}) echo "> Uploading the release artifacts" cd $REPO_DIR From 7a156a34511a85110786f8470fdd153f0b7be17b Mon Sep 17 00:00:00 2001 From: Elvis de Freitas Date: Mon, 20 Feb 2023 12:17:29 -0300 Subject: [PATCH 02/18] try to create artifacts in a new mode --- Dockerfile | 11 +---------- Dockerfile.builder | 11 ----------- Dockerfile.builder.linux-amd64 | 11 +++++++++++ builder.bash | 10 +++++++--- docker-compose.yml | 11 +++++++++-- src/main/resources/application.properties | 1 + 6 files changed, 29 insertions(+), 26 deletions(-) delete mode 100644 Dockerfile.builder create mode 100644 Dockerfile.builder.linux-amd64 diff --git a/Dockerfile b/Dockerfile index 827ff1678..eb33c0dcf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,5 @@ -FROM docker.io/defreitas/tools_graalvm-22.3_java-19_debian-9:0.1.1 AS BUILDER -COPY ./ /app -WORKDIR /app -RUN ./gradlew clean build -Dquarkus.package.type=native -i &&\ - cd build &&\ - ls -lha &&\ - mkdir -p artifacts &&\ - mv $(ls -p ./ | grep -v / | grep dns-proxy-server) ./artifacts/ - FROM debian:10-slim -COPY --from=BUILDER /app/build/artifacts/* /app/dns-proxy-server +COPY ./build/artifacts/linux-amd64/dns-proxy-server /app/dns-proxy-server WORKDIR /app LABEL dps.container=true VOLUME ["/var/run/docker.sock", "/var/run/docker.sock"] diff --git a/Dockerfile.builder b/Dockerfile.builder deleted file mode 100644 index f0978b0ed..000000000 --- a/Dockerfile.builder +++ /dev/null @@ -1,11 +0,0 @@ -FROM docker.io/defreitas/tools_graalvm-22.3_java-19_debian-9:0.1.1 AS BUILDER -COPY ./ /app -WORKDIR /app -RUN ./gradlew clean build -Dquarkus.package.type=native -i &&\ - ./gradlew -Dquarkus.package.type=uber-jar -i -x check &&\ - cd build && ls -lha &&\ - mkdir -p ./artifacts/linux-amd64 && mkdir -p ./artifacts/jre &&\ - mv $(ls -p | grep -v / | grep dns-proxy-server) ./artifacts/linux-amd64 &&\ - mv $(ls | grep -E 'dns-proxy-server.*\.jar') ./artifacts/jre - -ENTRYPOYINT cat diff --git a/Dockerfile.builder.linux-amd64 b/Dockerfile.builder.linux-amd64 new file mode 100644 index 000000000..8eebbdf5d --- /dev/null +++ b/Dockerfile.builder.linux-amd64 @@ -0,0 +1,11 @@ +FROM docker.io/defreitas/tools_graalvm-22.3_java-19_debian-9:0.1.1 AS BUILDER +COPY ./ /app +WORKDIR /app +RUN ./gradlew clean build -Dquarkus.package.type=native -i &&\ + ./gradlew build -Dquarkus.package.type=uber-jar -i -x check &&\ + ls -lha ./build &&\ + mkdir -p ./artifacts/linux-amd64 && mkdir -p ./artifacts/jre &&\ + mv ./build/dns-proxy-server ./artifacts/linux-amd64/ &&\ + mv ./build/dns-proxy-server.jar ./artifacts/jre/ + +ENTRYPOINT cat diff --git a/builder.bash b/builder.bash index 193be42a1..3c6443cca 100755 --- a/builder.bash +++ b/builder.bash @@ -60,16 +60,20 @@ case $1 in OS=linux ARCH=amd64 - SERVICE_NAME="build-${OS}-${ARCH}" + BUILD_SERVICE_NAME="build-${OS}-${ARCH}" + IMAGE_SERVICE_NAME="image-${OS}-${ARCH}" ARTIFACTS_DIR="${REPO_DIR}/build/artifacts" mkdir -p ${ARTIFACTS_DIR} + VERSION=${APP_VERSION} docker-compose build --progress=plain ${BUILD_SERVICE_NAME} + copyFileFromService ${BUILD_SERVICE_NAME} /app/build/artifacts /tmp/ + mv -v /tmp/artifacts/* ${ARTIFACTS_DIR} + + docker-compose build "${IMAGE_SERVICE_NAME}" # BIN_FILE="${REPO_DIR}/build/dns-proxy-server-${OS}-${ARCH}-${APP_VERSION}" # TAR_FILE=${BIN_FILE}.tgz - VERSION=${APP_VERSION} docker-compose build --progress=plain ${SERVICE_NAME} - copyFileFromService ${SERVICE_NAME} /app/build/artifacts ${ARTIFACTS_DIR} # cd $REPO_DIR/build/ # tar --exclude=*.tgz -czf $TAR_FILE $(basename ${BIN_FILE}) diff --git a/docker-compose.yml b/docker-compose.yml index 483895a34..7708089a5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,10 +12,17 @@ services: image: defreitas/dns-proxy-server:${VERSION:-snapshot} build: context: . - dockerfile: Dockerfile - + dockerfile: Dockerfile.builder.linux-amd64 # end:build + # tag:image + image-linux-amd64: + image: defreitas/dns-proxy-server:${VERSION:-snapshot} + build: + context: . + dockerfile: Dockerfile + # end:image + # tag:development # end:development diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ac4e08a6d..1cab91f62 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -13,5 +13,6 @@ quarkus.log.category."com.mageddo".level=DEBUG # quarkus-core-deployment-2.16.0.Final.jar!/META-INF/quarkus-javadoc.properties #quarkus.package.runner-suffix= +quarkus.package.output-name=dns-proxy-server quarkus.package.add-runner-suffix=false #quarkus.package.output-directory=artifacts From b0e9fab23a225eec19a9f0986c1dcc947db1c416 Mon Sep 17 00:00:00 2001 From: Elvis de Freitas Date: Mon, 20 Feb 2023 12:19:52 -0300 Subject: [PATCH 03/18] setup arm64 builder --- Dockerfile.builder.linux-arm64 | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Dockerfile.builder.linux-arm64 diff --git a/Dockerfile.builder.linux-arm64 b/Dockerfile.builder.linux-arm64 new file mode 100644 index 000000000..153e42205 --- /dev/null +++ b/Dockerfile.builder.linux-arm64 @@ -0,0 +1,9 @@ +FROM defreitas/tools_graalvm-22.3_java-17_debian-9_aarch64:0.1.2 +COPY ./ /app +WORKDIR /app +RUN ./gradlew clean build -Dquarkus.package.type=native -i &&\ + ls -lha ./build &&\ + mkdir -p ./artifacts/linux-arm64 &&\ + mv ./build/dns-proxy-server ./artifacts/linux-arm64/ + +ENTRYPOINT cat From a884ba61ef9248ea31f2c7b5ee61b7a1c4d1d3d1 Mon Sep 17 00:00:00 2001 From: Elvis de Freitas Date: Mon, 20 Feb 2023 12:26:35 -0300 Subject: [PATCH 04/18] adjustments --- ...linux-arm64 => Dockerfile.builder.linux-aarch64 | 0 Dockerfile.builder.linux-amd64 | 6 +++--- docker-compose.yml | 14 +++++++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) rename Dockerfile.builder.linux-arm64 => Dockerfile.builder.linux-aarch64 (100%) diff --git a/Dockerfile.builder.linux-arm64 b/Dockerfile.builder.linux-aarch64 similarity index 100% rename from Dockerfile.builder.linux-arm64 rename to Dockerfile.builder.linux-aarch64 diff --git a/Dockerfile.builder.linux-amd64 b/Dockerfile.builder.linux-amd64 index 8eebbdf5d..996cb8e3d 100644 --- a/Dockerfile.builder.linux-amd64 +++ b/Dockerfile.builder.linux-amd64 @@ -4,8 +4,8 @@ WORKDIR /app RUN ./gradlew clean build -Dquarkus.package.type=native -i &&\ ./gradlew build -Dquarkus.package.type=uber-jar -i -x check &&\ ls -lha ./build &&\ - mkdir -p ./artifacts/linux-amd64 && mkdir -p ./artifacts/jre &&\ - mv ./build/dns-proxy-server ./artifacts/linux-amd64/ &&\ - mv ./build/dns-proxy-server.jar ./artifacts/jre/ + mkdir -p ./build/artifacts/linux-amd64 && mkdir -p ./build/artifacts/jre &&\ + mv ./build/dns-proxy-server ./build/artifacts/linux-amd64/ &&\ + mv ./build/dns-proxy-server.jar ./build/artifacts/jre/ ENTRYPOINT cat diff --git a/docker-compose.yml b/docker-compose.yml index 7708089a5..121f4a5a1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,10 +9,16 @@ services: image: defreitas/dns-proxy-server-build-frontend:${VERSION:-snapshot} build-linux-amd64: - image: defreitas/dns-proxy-server:${VERSION:-snapshot} + image: defreitas/dns-proxy-server-build:${VERSION:-snapshot}-amd64 build: context: . dockerfile: Dockerfile.builder.linux-amd64 + + build-linux-aarch64: + image: defreitas/dns-proxy-server-build:${VERSION:-snapshot}-aarch64 + build: + context: . + dockerfile: Dockerfile.builder.linux-aarch64 # end:build # tag:image @@ -21,6 +27,12 @@ services: build: context: . dockerfile: Dockerfile + + image-linux-aarch64: + image: defreitas/dns-proxy-server:${VERSION:-snapshot}-aarch64 + build: + context: . + dockerfile: Dockerfile # end:image # tag:development From c330db69e3f09ef05ae5f049d38fa42f4928eafa Mon Sep 17 00:00:00 2001 From: Elvis de Freitas Date: Mon, 20 Feb 2023 12:36:46 -0300 Subject: [PATCH 05/18] it's owrking --- .dockerignore | 2 +- builder.bash | 5 ----- docker-compose.yml | 7 +++++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.dockerignore b/.dockerignore index 28ea54bea..f8451b27e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,5 @@ **/node_modules -build + #* #!build/*-runner #!build/*-runner.jar diff --git a/builder.bash b/builder.bash index 3c6443cca..2b41f8d8a 100755 --- a/builder.bash +++ b/builder.bash @@ -71,11 +71,6 @@ case $1 in mv -v /tmp/artifacts/* ${ARTIFACTS_DIR} docker-compose build "${IMAGE_SERVICE_NAME}" -# BIN_FILE="${REPO_DIR}/build/dns-proxy-server-${OS}-${ARCH}-${APP_VERSION}" -# TAR_FILE=${BIN_FILE}.tgz - -# cd $REPO_DIR/build/ -# tar --exclude=*.tgz -czf $TAR_FILE $(basename ${BIN_FILE}) ;; diff --git a/docker-compose.yml b/docker-compose.yml index 121f4a5a1..946598d0f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '2.3' +version: '3' services: # tag:build @@ -19,6 +19,8 @@ services: build: context: . dockerfile: Dockerfile.builder.linux-aarch64 + platform: linux/arm64/v8 + # end:build # tag:image @@ -32,7 +34,8 @@ services: image: defreitas/dns-proxy-server:${VERSION:-snapshot}-aarch64 build: context: . - dockerfile: Dockerfile + dockerfile: Dockerfile.aarch64 + # end:image # tag:development From 88b623d78939bbc74d7ee89a4c7c27d4ea765971 Mon Sep 17 00:00:00 2001 From: Elvis de Freitas Date: Mon, 20 Feb 2023 12:40:23 -0300 Subject: [PATCH 06/18] improvements --- Dockerfile.arm8x64 => Dockerfile.aarch64 | 2 +- Dockerfile.builder.linux-aarch64 | 2 +- builder.bash | 6 ++++-- docker-compose.yml | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) rename Dockerfile.arm8x64 => Dockerfile.aarch64 (68%) diff --git a/Dockerfile.arm8x64 b/Dockerfile.aarch64 similarity index 68% rename from Dockerfile.arm8x64 rename to Dockerfile.aarch64 index ba7862600..b3a09e74a 100644 --- a/Dockerfile.arm8x64 +++ b/Dockerfile.aarch64 @@ -1,5 +1,5 @@ FROM arm64v8/debian:10-slim -ADD build/dns-proxy-server-linux-arm64-*.tgz /app/ +COPY ./build/artifacts/linux-amd64/dns-proxy-server /app/dns-proxy-server WORKDIR /app LABEL dps.container=true VOLUME ["/var/run/docker.sock", "/var/run/docker.sock"] diff --git a/Dockerfile.builder.linux-aarch64 b/Dockerfile.builder.linux-aarch64 index 153e42205..71f5586f7 100644 --- a/Dockerfile.builder.linux-aarch64 +++ b/Dockerfile.builder.linux-aarch64 @@ -4,6 +4,6 @@ WORKDIR /app RUN ./gradlew clean build -Dquarkus.package.type=native -i &&\ ls -lha ./build &&\ mkdir -p ./artifacts/linux-arm64 &&\ - mv ./build/dns-proxy-server ./artifacts/linux-arm64/ + mv ./build/dns-proxy-server ./artifacts/linux-aarch64/ ENTRYPOINT cat diff --git a/builder.bash b/builder.bash index 2b41f8d8a..314891591 100755 --- a/builder.bash +++ b/builder.bash @@ -59,7 +59,8 @@ case $1 in build-backend ) OS=linux - ARCH=amd64 +# ARCH=amd64 + ARCH=aarch64 BUILD_SERVICE_NAME="build-${OS}-${ARCH}" IMAGE_SERVICE_NAME="image-${OS}-${ARCH}" ARTIFACTS_DIR="${REPO_DIR}/build/artifacts" @@ -67,10 +68,11 @@ case $1 in mkdir -p ${ARTIFACTS_DIR} VERSION=${APP_VERSION} docker-compose build --progress=plain ${BUILD_SERVICE_NAME} + copyFileFromService ${BUILD_SERVICE_NAME} /app/build/artifacts /tmp/ mv -v /tmp/artifacts/* ${ARTIFACTS_DIR} - docker-compose build "${IMAGE_SERVICE_NAME}" + VERSION=${APP_VERSION} docker-compose build "${IMAGE_SERVICE_NAME}" ;; diff --git a/docker-compose.yml b/docker-compose.yml index 946598d0f..97c335b85 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -51,5 +51,5 @@ services: prod-build-image-dps-arm8x64: build: context: . - dockerfile: Dockerfile.arm8x64 + dockerfile: Dockerfile.aarch64 image: defreitas/dns-proxy-server:${VERSION:-snapshot}-arm8x64 From f762a93360f801a931fd58e273dbec66e3efe609 Mon Sep 17 00:00:00 2001 From: Elvis de Freitas Date: Mon, 20 Feb 2023 13:44:56 -0300 Subject: [PATCH 07/18] new way to build aarch binary --- DRAFT.md | 25 ++++++++++++++++++++++++ Dockerfile.aarch64 | 2 +- Dockerfile.builder.linux-aarch64 | 33 +++++++++++++++++++++++++------- 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/DRAFT.md b/DRAFT.md index 5644f96b8..9ef7bcb6a 100644 --- a/DRAFT.md +++ b/DRAFT.md @@ -72,3 +72,28 @@ java -cp './build/dns-proxy-server-3.0.0-alpha-runner.jar:../annotation-process docker-compose -f docker-compose-tmp.yml up --build + +## To build native image manually when using quarkus +Command copied from `./gradlew clean build -Dquarkus.package.type=native -i -x check` + +```bash +$ cd build/dns-proxy-server-native-image-source-jar +$ native-image -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dsun.nio.ch.maxUpdateArraySize=100 \ +-J-Dlogging.initial-configurator.min-level=500 -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=3 \ +-J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory \ +-J-Dvertx.disableDnsResolver=true -J-Duser.language=en -J-Duser.country=US -J-Dfile.encoding=UTF-8 \ +--features=io.quarkus.runner.Feature,io.quarkus.runtime.graal.ResourcesFeature,io.quarkus.runtime.graal.DisableLoggingFeature \ +-J--add-exports=java.security.jgss/sun.security.krb5=ALL-UNNAMED -J--add-opens=java.base/java.text=ALL-UNNAMED \ +-J--add-opens=java.base/java.io=ALL-UNNAMED -J--add-opens=java.base/java.lang.invoke=ALL-UNNAMED \ +-J--add-opens=java.base/java.util=ALL-UNNAMED -H:+CollectImageBuildStatistics \ +-H:ImageBuildStatisticsFile=dns-proxy-server-timing-stats.json \ +-H:BuildOutputJSONFile=dns-proxy-server-build-output-stats.json -H:+AllowFoldMethods -J-Djava.awt.headless=true \ +--no-fallback --link-at-build-time -H:+ReportExceptionStackTraces -H:-AddAllCharsets --enable-url-protocols=http \ +-H:NativeLinkerOption=-no-pie -H:-UseServiceLoaderFeature -H:+StackTrace \ +-J--add-exports=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED \ +-J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED \ +--exclude-config io\.netty\.netty-codec /META-INF/native-image/io\.netty/netty-codec/generated/handlers/reflect-config\.json \ +--exclude-config io\.netty\.netty-handler /META-INF/native-image/io\.netty/netty-handler/generated/handlers/reflect-config\.json dns-proxy-server \ +-jar dns-proxy-server.jar + +``` diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index b3a09e74a..b3814f3b1 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -1,5 +1,5 @@ FROM arm64v8/debian:10-slim -COPY ./build/artifacts/linux-amd64/dns-proxy-server /app/dns-proxy-server +COPY ./build/artifacts/linux-aarch/dns-proxy-server /app/dns-proxy-server WORKDIR /app LABEL dps.container=true VOLUME ["/var/run/docker.sock", "/var/run/docker.sock"] diff --git a/Dockerfile.builder.linux-aarch64 b/Dockerfile.builder.linux-aarch64 index 71f5586f7..cba42f40b 100644 --- a/Dockerfile.builder.linux-aarch64 +++ b/Dockerfile.builder.linux-aarch64 @@ -1,9 +1,28 @@ -FROM defreitas/tools_graalvm-22.3_java-17_debian-9_aarch64:0.1.2 -COPY ./ /app -WORKDIR /app -RUN ./gradlew clean build -Dquarkus.package.type=native -i &&\ - ls -lha ./build &&\ - mkdir -p ./artifacts/linux-arm64 &&\ - mv ./build/dns-proxy-server ./artifacts/linux-aarch64/ +FROM defreitas/tools_graalvm-22.3_java-17_debian-9_aarch64:0.1.3 +WORKDIR /app/build +COPY ./build/artifacts/native-image-source/ /app/build + +RUN ls -lha &&\ + native-image -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dsun.nio.ch.maxUpdateArraySize=100 \ + -J-Dlogging.initial-configurator.min-level=500 -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=3 \ + -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory \ + -J-Dvertx.disableDnsResolver=true -J-Duser.language=en -J-Duser.country=US -J-Dfile.encoding=UTF-8 \ + --features=io.quarkus.runner.Feature,io.quarkus.runtime.graal.ResourcesFeature,io.quarkus.runtime.graal.DisableLoggingFeature \ + -J--add-exports=java.security.jgss/sun.security.krb5=ALL-UNNAMED -J--add-opens=java.base/java.text=ALL-UNNAMED \ + -J--add-opens=java.base/java.io=ALL-UNNAMED -J--add-opens=java.base/java.lang.invoke=ALL-UNNAMED \ + -J--add-opens=java.base/java.util=ALL-UNNAMED -H:+CollectImageBuildStatistics \ + -H:ImageBuildStatisticsFile=dns-proxy-server-timing-stats.json \ + -H:BuildOutputJSONFile=dns-proxy-server-build-output-stats.json -H:+AllowFoldMethods -J-Djava.awt.headless=true \ + --no-fallback --link-at-build-time -H:+ReportExceptionStackTraces -H:-AddAllCharsets --enable-url-protocols=http \ + -H:NativeLinkerOption=-no-pie -H:-UseServiceLoaderFeature -H:+StackTrace \ + -J--add-exports=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED \ + -J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED \ + --exclude-config io\.netty\.netty-codec /META-INF/native-image/io\.netty/netty-codec/generated/handlers/reflect-config\.json \ + --exclude-config io\.netty\.netty-handler /META-INF/native-image/io\.netty/netty-handler/generated/handlers/reflect-config\.json dns-proxy-server \ + -jar dns-proxy-server.jar + +RUN ls lha &&\ + mkdir -p ./artifacts/linux-aarch64 &&\ + mv ./dns-proxy-server ./artifacts/linux-aarch64/ ENTRYPOINT cat From 1cc082ce52122b33559b5042a3e48ec531718e70 Mon Sep 17 00:00:00 2001 From: Elvis de Freitas Date: Mon, 20 Feb 2023 14:38:36 -0300 Subject: [PATCH 08/18] Looks like fixed arm build --- Dockerfile.builder.linux-aarch64 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile.builder.linux-aarch64 b/Dockerfile.builder.linux-aarch64 index cba42f40b..c79229d2f 100644 --- a/Dockerfile.builder.linux-aarch64 +++ b/Dockerfile.builder.linux-aarch64 @@ -2,8 +2,9 @@ FROM defreitas/tools_graalvm-22.3_java-17_debian-9_aarch64:0.1.3 WORKDIR /app/build COPY ./build/artifacts/native-image-source/ /app/build -RUN ls -lha &&\ - native-image -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dsun.nio.ch.maxUpdateArraySize=100 \ +ENV JAVA_TOOL_OPTIONS='-Djdk.lang.Process.launchMechanism=fork' +RUN uname -m && ls -lha &&\ + native-image -Djdk.lang.Process.launchMechanism=fork -J-Djdk.lang.Process.launchMechanism=fork -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dsun.nio.ch.maxUpdateArraySize=100 \ -J-Dlogging.initial-configurator.min-level=500 -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=3 \ -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory \ -J-Dvertx.disableDnsResolver=true -J-Duser.language=en -J-Duser.country=US -J-Dfile.encoding=UTF-8 \ From e43864970f9ae2759f6fe0ed2bffff175cc405bc Mon Sep 17 00:00:00 2001 From: Elvis de Freitas Date: Mon, 20 Feb 2023 14:41:00 -0300 Subject: [PATCH 09/18] exporting native-image-source --- Dockerfile.builder.linux-amd64 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Dockerfile.builder.linux-amd64 b/Dockerfile.builder.linux-amd64 index 996cb8e3d..0419e40aa 100644 --- a/Dockerfile.builder.linux-amd64 +++ b/Dockerfile.builder.linux-amd64 @@ -4,8 +4,7 @@ WORKDIR /app RUN ./gradlew clean build -Dquarkus.package.type=native -i &&\ ./gradlew build -Dquarkus.package.type=uber-jar -i -x check &&\ ls -lha ./build &&\ - mkdir -p ./build/artifacts/linux-amd64 && mkdir -p ./build/artifacts/jre &&\ - mv ./build/dns-proxy-server ./build/artifacts/linux-amd64/ &&\ - mv ./build/dns-proxy-server.jar ./build/artifacts/jre/ - + mkdir -p ./build/artifacts/linux-amd64 && mv ./build/dns-proxy-server ./build/artifacts/linux-amd64/ &&\ + mkdir -p ./build/artifacts/jre && mv ./build/dns-proxy-server.jar ./build/artifacts/jre/ &&\ + mv ./build/dns-proxy-server-native-image-source-jar ./build/artifacts/native-image-source ENTRYPOINT cat From 907e3c1a7c20b956be9df8d5a2600e338cd09f89 Mon Sep 17 00:00:00 2001 From: Elvis de Freitas Date: Mon, 20 Feb 2023 14:50:49 -0300 Subject: [PATCH 10/18] fixed --- Dockerfile.builder.linux-aarch64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.builder.linux-aarch64 b/Dockerfile.builder.linux-aarch64 index c79229d2f..c19765488 100644 --- a/Dockerfile.builder.linux-aarch64 +++ b/Dockerfile.builder.linux-aarch64 @@ -22,7 +22,7 @@ RUN uname -m && ls -lha &&\ --exclude-config io\.netty\.netty-handler /META-INF/native-image/io\.netty/netty-handler/generated/handlers/reflect-config\.json dns-proxy-server \ -jar dns-proxy-server.jar -RUN ls lha &&\ +RUN ls -lha &&\ mkdir -p ./artifacts/linux-aarch64 &&\ mv ./dns-proxy-server ./artifacts/linux-aarch64/ From 6c7cd0356f5383b220d2c1b9d5c49a2f2bc39064 Mon Sep 17 00:00:00 2001 From: Elvis de Freitas Date: Mon, 20 Feb 2023 15:17:46 -0300 Subject: [PATCH 11/18] adjustments --- builder.bash | 62 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/builder.bash b/builder.bash index 314891591..e8a040558 100755 --- a/builder.bash +++ b/builder.bash @@ -59,47 +59,69 @@ case $1 in build-backend ) OS=linux -# ARCH=amd64 - ARCH=aarch64 + ARCH=$1 BUILD_SERVICE_NAME="build-${OS}-${ARCH}" IMAGE_SERVICE_NAME="image-${OS}-${ARCH}" ARTIFACTS_DIR="${REPO_DIR}/build/artifacts" + echo "> building backend to: os=${OS}, arch=${ARCH}" + mkdir -p ${ARTIFACTS_DIR} - VERSION=${APP_VERSION} docker-compose build --progress=plain ${BUILD_SERVICE_NAME} + VERSION=${APP_VERSION} \ + docker-compose build --progress=plain ${BUILD_SERVICE_NAME} copyFileFromService ${BUILD_SERVICE_NAME} /app/build/artifacts /tmp/ mv -v /tmp/artifacts/* ${ARTIFACTS_DIR} - VERSION=${APP_VERSION} docker-compose build "${IMAGE_SERVICE_NAME}" + VERSION=${APP_VERSION} \ + docker-compose build --progress=plain "${IMAGE_SERVICE_NAME}" ;; - deploy ) + compress-upload-artifacts ) + echo "> compress the files ..." - echo "> Deploy started , current branch=$CURRENT_BRANCH" - ./builder.bash validate-release || exit 0 + ARTIFACTS_DIR="${REPO_DIR}/build/artifacts" + COMPRESSED_ARTIFACTS_DIR="${REPO_DIR}/build/compressed-artifacts" - ./builder.bash build-frontend + mkdir -p ${COMPRESSED_ARTIFACTS_DIR} + cd ${ARTIFACTS_DIR} + + ls ${ARTIFACTS_DIR} | grep -v "native-image-source" |\ + while read -r f ; do + tgz="${COMPRESSED_ARTIFACTS_DIR}/dns-proxy-server-${f}.tgz" + tar -czvf ${tgz} ${f} + echo "> compressed ${f} to ${tgz} ..." + done + + echo "> Uploading the release artifacts" + cd $REPO_DIR + DESC=$(cat RELEASE-NOTES.md | awk 'BEGIN {RS="|"} {print substr($0, 0, index(substr($0, 3), "###"))}' | sed ':a;N;$!ba;s/\n/\\r\\n/g') + github-cli release mageddo dns-proxy-server $APP_VERSION $CURRENT_BRANCH "${DESC}" ${COMPRESSED_ARTIFACTS_DIR}/*.tgz - ./builder.bash build-backend + ;; + + docker-push ) + echo "> Push docker images to docker hub" + docker tag defreitas/dns-proxy-server:${APP_VERSION} defreitas/dns-proxy-server:latest &&\ + echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin &&\ + VERSION=${APP_VERSION} docker-compose push image-linux-amd64 image-linux-aarch64 + ;; + + deploy ) + echo "> Deploy started , current branch=$CURRENT_BRANCH" + ./builder.bash validate-release || exit 0 - echo "> Uploading the release artifacts" - cd $REPO_DIR - DESC=$(cat RELEASE-NOTES.md | awk 'BEGIN {RS="|"} {print substr($0, 0, index(substr($0, 3), "###"))}' | sed ':a;N;$!ba;s/\n/\\r\\n/g') - github-cli release mageddo dns-proxy-server $APP_VERSION $CURRENT_BRANCH "${DESC}" $REPO_DIR/build/*.tgz + ./builder.bash build-frontend + ./builder.bash build-backend amd64 #also builds the jar + ./builder.bash build-backend aarch64 - echo "> Push docker images to docker hub" -# docker-compose build prod-build-image-dps prod-build-image-dps-arm7x86 prod-build-image-dps-arm8x64 &&\ -# docker tag defreitas/dns-proxy-server:${APP_VERSION} defreitas/dns-proxy-server:latest &&\ - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin &&\ - VERSION=${APP_VERSION} docker-compose push build-linux-amd64 -# docker-compose push prod-build-image-dps prod-build-image-dps-arm7x86 prod-build-image-dps-arm8x64 && -# docker push defreitas/dns-proxy-server:latest + ./builder.bash compress-upload-artifacts + ./builder.bash docker-push ;; deploy-docs ) From b72215a3cf23ec68608355e7870438d024bfcd94 Mon Sep 17 00:00:00 2001 From: Elvis de Freitas Date: Mon, 20 Feb 2023 15:21:55 -0300 Subject: [PATCH 12/18] new version --- .github/workflows/actions-deploy.yml | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/actions-deploy.yml b/.github/workflows/actions-deploy.yml index c088535d5..d7196050a 100644 --- a/.github/workflows/actions-deploy.yml +++ b/.github/workflows/actions-deploy.yml @@ -24,7 +24,7 @@ jobs: fetch-depth: '0' - name: Deploy - run: docker-compose -f docker-compose-deploy.yml up --force-recreate --exit-code-from deploy deploy +# run: docker-compose -f docker-compose-deploy.yml up --force-recreate --exit-code-from deploy deploy env: # github token to deploy the binary REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/gradle.properties b/gradle.properties index b5f17aa5f..8f0f7f04d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=3.0.2-beta +version=3.0.3-beta quarkusPluginId=io.quarkus quarkusPluginVersion=2.16.0.Final quarkusPlatformGroupId=io.quarkus.platform From 9f547e8ee07b0a5b45401ae78342a095f3043660 Mon Sep 17 00:00:00 2001 From: Elvis de Freitas Date: Mon, 20 Feb 2023 15:22:08 -0300 Subject: [PATCH 13/18] new version --- .github/workflows/actions-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/actions-deploy.yml b/.github/workflows/actions-deploy.yml index d7196050a..c088535d5 100644 --- a/.github/workflows/actions-deploy.yml +++ b/.github/workflows/actions-deploy.yml @@ -24,7 +24,7 @@ jobs: fetch-depth: '0' - name: Deploy -# run: docker-compose -f docker-compose-deploy.yml up --force-recreate --exit-code-from deploy deploy + run: docker-compose -f docker-compose-deploy.yml up --force-recreate --exit-code-from deploy deploy env: # github token to deploy the binary REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 970fcc7be93abdda0ef703dd0173e19e5ba58bcf Mon Sep 17 00:00:00 2001 From: Elvis de Freitas Date: Mon, 20 Feb 2023 15:25:41 -0300 Subject: [PATCH 14/18] force to not use cache --- .github/workflows/actions-deploy.yml | 2 +- builder.bash | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/actions-deploy.yml b/.github/workflows/actions-deploy.yml index c088535d5..36960b986 100644 --- a/.github/workflows/actions-deploy.yml +++ b/.github/workflows/actions-deploy.yml @@ -24,7 +24,7 @@ jobs: fetch-depth: '0' - name: Deploy - run: docker-compose -f docker-compose-deploy.yml up --force-recreate --exit-code-from deploy deploy + run: docker-compose -f docker-compose-deploy.yml up --build --force-recreate --exit-code-from deploy deploy env: # github token to deploy the binary REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/builder.bash b/builder.bash index e8a040558..56a11032a 100755 --- a/builder.bash +++ b/builder.bash @@ -44,10 +44,9 @@ case $1 in ;; build-frontend ) - ./builder.bash validate-release || exit 0 echo "> Building frontend files..." - docker-compose build --progress=plain build-frontend + docker-compose build --no-cache --progress=plain build-frontend rm -rf ./src/main/resources/META-INF/resources/static copyFileFromService build-frontend /static ./src/main/resources/META-INF/resources/static @@ -69,18 +68,19 @@ case $1 in mkdir -p ${ARTIFACTS_DIR} VERSION=${APP_VERSION} \ - docker-compose build --progress=plain ${BUILD_SERVICE_NAME} + docker-compose build --no-cache --progress=plain ${BUILD_SERVICE_NAME} copyFileFromService ${BUILD_SERVICE_NAME} /app/build/artifacts /tmp/ mv -v /tmp/artifacts/* ${ARTIFACTS_DIR} VERSION=${APP_VERSION} \ - docker-compose build --progress=plain "${IMAGE_SERVICE_NAME}" + docker-compose build --no-cache --progress=plain "${IMAGE_SERVICE_NAME}" ;; compress-upload-artifacts ) echo "> compress the files ..." + ./builder.bash validate-release || exit 0 ARTIFACTS_DIR="${REPO_DIR}/build/artifacts" COMPRESSED_ARTIFACTS_DIR="${REPO_DIR}/build/compressed-artifacts" From 866833b69073857e17b4103e75b885308836d2d2 Mon Sep 17 00:00:00 2001 From: Elvis de Freitas Date: Mon, 20 Feb 2023 15:41:17 -0300 Subject: [PATCH 15/18] adjusting copy --- builder.bash | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/builder.bash b/builder.bash index 56a11032a..27ec57f84 100755 --- a/builder.bash +++ b/builder.bash @@ -4,6 +4,7 @@ set -e REPO_DIR=`pwd` APP_VERSION=$(cat gradle.properties | grep -oP 'version=\K(.+)') +export VERSION=${APP_VERSION} echo "> builder.bash version=${APP_VERSION}, path=${REPO_DIR}" @@ -24,8 +25,8 @@ copyFileFromService(){ from=$2 to=$3 - docker-compose up --no-start --build --force-recreate $serviceName 1>&2 - id=$(docker ps -a | grep $serviceName | awk '{print $1}') + id=$(docker-compose up --no-start --build --force-recreate $serviceName 2>&1 | grep Container | awk '{print $2}' | head -1) + echo "> copy from service=${serviceName}, id=${id}, from=${from}, to=${to}" docker cp "$id:$from" "$to" } @@ -39,6 +40,10 @@ validateRelease(){ case $1 in + copy ) + copyFileFromService build-frontend /static ./src/main/resources/META-INF/resources/static + ;; + validate-release ) validateRelease ;; @@ -67,13 +72,11 @@ case $1 in mkdir -p ${ARTIFACTS_DIR} - VERSION=${APP_VERSION} \ docker-compose build --no-cache --progress=plain ${BUILD_SERVICE_NAME} copyFileFromService ${BUILD_SERVICE_NAME} /app/build/artifacts /tmp/ mv -v /tmp/artifacts/* ${ARTIFACTS_DIR} - VERSION=${APP_VERSION} \ docker-compose build --no-cache --progress=plain "${IMAGE_SERVICE_NAME}" ;; @@ -112,6 +115,8 @@ case $1 in deploy ) echo "> Deploy started , current branch=$CURRENT_BRANCH" + rm -vrf build + ls -lha ./builder.bash validate-release || exit 0 From f4c3e8673c1105f6e1f39ab498aca829bdc59a28 Mon Sep 17 00:00:00 2001 From: Elvis de Freitas Date: Mon, 20 Feb 2023 15:52:02 -0300 Subject: [PATCH 16/18] unnecessary var --- .github/workflows/actions-deploy.yml | 4 ++++ builder.bash | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/actions-deploy.yml b/.github/workflows/actions-deploy.yml index 36960b986..d7173516e 100644 --- a/.github/workflows/actions-deploy.yml +++ b/.github/workflows/actions-deploy.yml @@ -4,6 +4,10 @@ on: branches: - master +#on: +# pull_request: + + permissions: contents: write diff --git a/builder.bash b/builder.bash index 27ec57f84..009f6452c 100755 --- a/builder.bash +++ b/builder.bash @@ -63,7 +63,7 @@ case $1 in build-backend ) OS=linux - ARCH=$1 + ARCH=$2 BUILD_SERVICE_NAME="build-${OS}-${ARCH}" IMAGE_SERVICE_NAME="image-${OS}-${ARCH}" ARTIFACTS_DIR="${REPO_DIR}/build/artifacts" @@ -109,7 +109,7 @@ case $1 in echo "> Push docker images to docker hub" docker tag defreitas/dns-proxy-server:${APP_VERSION} defreitas/dns-proxy-server:latest &&\ echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin &&\ - VERSION=${APP_VERSION} docker-compose push image-linux-amd64 image-linux-aarch64 + docker-compose push image-linux-amd64 image-linux-aarch64 ;; deploy ) From 3542cfec9b27184795c51664261b3dff3e9e23bb Mon Sep 17 00:00:00 2001 From: Elvis de Freitas Date: Mon, 20 Feb 2023 15:56:27 -0300 Subject: [PATCH 17/18] setup qemu --- .github/workflows/actions-deploy.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/actions-deploy.yml b/.github/workflows/actions-deploy.yml index d7173516e..2fd79b5bb 100644 --- a/.github/workflows/actions-deploy.yml +++ b/.github/workflows/actions-deploy.yml @@ -27,6 +27,9 @@ jobs: with: fetch-depth: '0' + - name: Configure Qemu + run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + - name: Deploy run: docker-compose -f docker-compose-deploy.yml up --build --force-recreate --exit-code-from deploy deploy env: From 09a73cfd88d2cb0c57f78bb4f47a8db28226b721 Mon Sep 17 00:00:00 2001 From: Elvis de Freitas Date: Mon, 20 Feb 2023 16:10:46 -0300 Subject: [PATCH 18/18] adjusting and praying --- .github/workflows/actions-deploy.yml | 11 +++++------ Dockerfile.aarch64 | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/actions-deploy.yml b/.github/workflows/actions-deploy.yml index 2fd79b5bb..242913a07 100644 --- a/.github/workflows/actions-deploy.yml +++ b/.github/workflows/actions-deploy.yml @@ -1,12 +1,11 @@ name: CD -on: - push: - branches: - - master - #on: -# pull_request: +# push: +# branches: +# - master +on: + pull_request: permissions: contents: write diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index b3814f3b1..d772a4e3e 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -1,5 +1,5 @@ FROM arm64v8/debian:10-slim -COPY ./build/artifacts/linux-aarch/dns-proxy-server /app/dns-proxy-server +COPY ./build/artifacts/linux-aarch64/dns-proxy-server /app/dns-proxy-server WORKDIR /app LABEL dps.container=true VOLUME ["/var/run/docker.sock", "/var/run/docker.sock"]