diff --git a/hawkbit-runtime/docker/dockerfiles/Dockerfile b/hawkbit-runtime/docker/docker_build/Dockerfile similarity index 100% rename from hawkbit-runtime/docker/dockerfiles/Dockerfile rename to hawkbit-runtime/docker/docker_build/Dockerfile diff --git a/hawkbit-runtime/docker/dockerfiles/Dockerfile-mysql b/hawkbit-runtime/docker/docker_build/Dockerfile-mysql similarity index 98% rename from hawkbit-runtime/docker/dockerfiles/Dockerfile-mysql rename to hawkbit-runtime/docker/docker_build/Dockerfile-mysql index b09ef4b99..d1b2ff669 100644 --- a/hawkbit-runtime/docker/dockerfiles/Dockerfile-mysql +++ b/hawkbit-runtime/docker/docker_build/Dockerfile-mysql @@ -45,7 +45,7 @@ COPY --from=build ${BUILD_DIR}/spring-boot-loader/ ./ COPY --from=build ${BUILD_DIR}/snapshot-dependencies/ ./ COPY --from=build ${BUILD_DIR}/application/ ./ ARG MARIADB_DRIVER_VERSION=3.1.4 -COPY --from=build ${BUILD_DIR}/mariadb-java-client-${MARIADB_DRIVER_VERSION}.jar/ ./BOOT-INF/lib/ +COPY --from=build ${BUILD_DIR}/mariadb-java-client-${MARIADB_DRIVER_VERSION}.jar ./BOOT-INF/lib/ ARG CONTAINER_PORT=8080 ENV JAVA_OPTS="-Dspring.profiles.active=mysql -Xms768m -Xmx768m -XX:MaxMetaspaceSize=250m -XX:MetaspaceSize=250m -Xss300K -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+UseCompressedOops -XX:+HeapDumpOnOutOfMemoryError" diff --git a/hawkbit-runtime/docker/docker_build/Dockerfile_dev b/hawkbit-runtime/docker/docker_build/Dockerfile_dev new file mode 100644 index 000000000..d125b91a0 --- /dev/null +++ b/hawkbit-runtime/docker/docker_build/Dockerfile_dev @@ -0,0 +1,36 @@ +# set Java +ARG JAVA_VERSION=17.0.9_9 +# extracts spring layers from the app jar (to optimize boot) +FROM eclipse-temurin:${JAVA_VERSION}-jre-alpine as build + +ARG HAWKBIT_APP=hawkbit-update-server +ARG HAWKBIT_VERSION=0.3.0 + +ENV BUILD_DIR=/opt/hawkbit_build +ENV APP=${HAWKBIT_APP} +ENV VERSION=${HAWKBIT_VERSION} + +COPY org/eclipse/hawkbit/${APP}/${VERSION}/${APP}-${VERSION}.jar ${APP}-${VERSION}.jar + +RUN set -x &&\ + mkdir -p ${BUILD_DIR} &&\ + cd ${BUILD_DIR} &&\ + java -Djarmode=layertools -jar /${APP}-${VERSION}.jar extract --destination . &&\ + rm /${APP}-${VERSION}.jar + +FROM eclipse-temurin:${JAVA_VERSION}-jre-alpine + +RUN addgroup -S rollouts && adduser -D sp -G rollouts +USER sp + +ENV BUILD_DIR=/opt/hawkbit_build +COPY --from=build ${BUILD_DIR}/dependencies/ ./ +COPY --from=build ${BUILD_DIR}/spring-boot-loader/ ./ +COPY --from=build ${BUILD_DIR}/snapshot-dependencies/ ./ +COPY --from=build ${BUILD_DIR}/application/ ./ + +ARG CONTAINER_PORT=8080 +ENV JAVA_OPTS="-Xms768m -Xmx768m -XX:MaxMetaspaceSize=250m -XX:MetaspaceSize=250m -Xss300K -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+UseCompressedOops -XX:+HeapDumpOnOutOfMemoryError" + +EXPOSE ${CONTAINER_PORT} +ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} org.springframework.boot.loader.JarLauncher ${@}"] diff --git a/hawkbit-runtime/docker/docker_build/Dockerfile_dev-mysql b/hawkbit-runtime/docker/docker_build/Dockerfile_dev-mysql new file mode 100644 index 000000000..edfb79fb5 --- /dev/null +++ b/hawkbit-runtime/docker/docker_build/Dockerfile_dev-mysql @@ -0,0 +1,38 @@ +# set Java +ARG JAVA_VERSION=17.0.9_9 +# extracts spring layers from the app jar (to optimize boot) +FROM eclipse-temurin:${JAVA_VERSION}-jre-alpine as build + +ARG HAWKBIT_APP=hawkbit-update-server +ARG HAWKBIT_VERSION=0.3.0 + +ENV BUILD_DIR=/opt/hawkbit_build +ENV APP=${HAWKBIT_APP} +ENV VERSION=${HAWKBIT_VERSION} + +COPY org/eclipse/hawkbit/${APP}/${VERSION}/${APP}-${VERSION}.jar ${APP}-${VERSION}.jar + +RUN set -x &&\ + mkdir -p ${BUILD_DIR} &&\ + cd ${BUILD_DIR} &&\ + java -Djarmode=layertools -jar /${APP}-${VERSION}.jar extract --destination . &&\ + rm /${APP}-${VERSION}.jar + +FROM eclipse-temurin:${JAVA_VERSION}-jre-alpine + +RUN addgroup -S rollouts && adduser -D sp -G rollouts +USER sp + +ENV BUILD_DIR=/opt/hawkbit_build +COPY --from=build ${BUILD_DIR}/dependencies/ ./ +COPY --from=build ${BUILD_DIR}/spring-boot-loader/ ./ +COPY --from=build ${BUILD_DIR}/snapshot-dependencies/ ./ +COPY --from=build ${BUILD_DIR}/application/ ./ +ARG MARIADB_DRIVER_VERSION=3.1.4 +COPY org/mariadb/jdbc/mariadb-java-client/${MARIADB_DRIVER_VERSION}/mariadb-java-client-${MARIADB_DRIVER_VERSION}.jar ./BOOT-INF/lib/ + +ARG CONTAINER_PORT=8080 +ENV JAVA_OPTS="-Dspring.profiles.active=mysql -Xms768m -Xmx768m -XX:MaxMetaspaceSize=250m -XX:MetaspaceSize=250m -Xss300K -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+UseCompressedOops -XX:+HeapDumpOnOutOfMemoryError" + +EXPOSE ${CONTAINER_PORT} +ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} org.springframework.boot.loader.JarLauncher ${@}"] diff --git a/hawkbit-runtime/docker/dockerfiles/KEY b/hawkbit-runtime/docker/docker_build/KEY similarity index 100% rename from hawkbit-runtime/docker/dockerfiles/KEY rename to hawkbit-runtime/docker/docker_build/KEY diff --git a/hawkbit-runtime/docker/dockerfiles/KEY-mysql b/hawkbit-runtime/docker/docker_build/KEY-mysql similarity index 100% rename from hawkbit-runtime/docker/dockerfiles/KEY-mysql rename to hawkbit-runtime/docker/docker_build/KEY-mysql diff --git a/hawkbit-runtime/docker/docker_build/README.md b/hawkbit-runtime/docker/docker_build/README.md new file mode 100644 index 000000000..df02c8eac --- /dev/null +++ b/hawkbit-runtime/docker/docker_build/README.md @@ -0,0 +1,55 @@ +hawkBit Docker Build +=== +This directory contains docker files for building both hawkBit docker flavours: +* _standard_ - hawkBit images without mysql driver +* _mysql_ - with MariaDB Java connector with support for MySQL. + +Both flavours of are almost the same, just mysql has in addition a MariaDB Java connector and is started, by default, with mysql Spring profile. + +For every flavour there are two build types: +* _default_ - uses officially released hawkBit versions, downloading them from https://repo1.maven.org +* _development/dev_ - uses the local maven repository with built by developer (or just downloaded from any maven repository) hawkBit applications + +## Build overview +Building images supports the following build arguments (i.e. ARG-s which could be passed using _--build-arg_): +* _JAVA_VERSION_ - **[OPTIONAL, if not set a default is used]** the Java version of the eclipse-temurin jre-alpine base image to be used. +* _HAWKBIT_APP_ - **[OPTIONAL, if not set _hawkbit-update-server_ is used]** the application to be build. Currently, there is just _hawkbit-update-server_ but in future, if hawkBit is split to micro-services, there could be different micro-service apps. +* _HAWKBIT_VERSION_ - **[OPTIONAL, if not set a default, should be the last officially released version, is used]** the application version +* _CONTAINER_PORT_ - **[OPTIONAL, if not set 8080 is used]** on which the app opens the http server (if available) +* _MARIADB_DRIVER_VERSION_ (mysql flavours only!) - **[OPTIONAL, if not set a default is used]** the version of MariaDB connector to be used + +Additionally, tge _development_ builds shall be started with docker build context the local maven repository + +## Build standard +Standard flavour could be build, for example, with: +```shell +docker build --build-arg HAWKBIT_APP=hawkbit-update-server -t hawkbit_update_server:0.3.0 . -f Dockerfile +``` +or just by: +```shell +docker build -t hawkbit_update_server:0.3.0 . +``` +having that docker uses by default _Dockerfile_ and the _hawkbit-update-server_ is the default _HAWKBIT_APP_. + +To build development docker images, e.g. snapshot based, you could use something like: +```shell +docker build -t hawkbit_update_server:0.4.0-SNAPSHOT -f Dockerfile_dev ~/.m2/repository +``` +Note that here you have to use your maven repository containing the hawkBit app as docker build context, in the example case _~/.m2/repository_ + +## Build mysql +Mysql flavour could be build, for example, with: +```shell +docker build --build-arg HAWKBIT_APP=hawkbit-update-server -t hawkbit_update_server:0.3.0-mysql . -f Dockerfile-mysql +``` +or just by: +```shell +docker build --build-arg -t hawkbit_update_server:0.3.0-mysql . -f Dockerfile-mysql +``` +having that the _hawkbit-update-server_ is the default _HAWKBIT_APP_. + +To build development docker images, e.g. snapshot based, you could use something like: +```shell +docker build -t hawkbit_update_server:0.4.0-SNAPSHOT-mysql -f Dockerfile_dev-mysql ~/.m2/repository +``` +Note that here you have to use your maven repository containing the hawkBit app as docker build context, in the example case _~/.m2/repository_ \ No newline at end of file diff --git a/hawkbit-runtime/docker/dockerfiles/README.md b/hawkbit-runtime/docker/dockerfiles/README.md deleted file mode 100644 index 21998385b..000000000 --- a/hawkbit-runtime/docker/dockerfiles/README.md +++ /dev/null @@ -1,24 +0,0 @@ -hawkBit Docker -=== -Build files for both hawkbit docker flavours - standard (no mysql driver) and mysql (with MariaDB Java connector with support for MySQL). - -## Build overview -Images are built using _Dockerfile_ or _Dockerfile-mysql_. They accept _ARG_ build parameters _JAVA_VERSION_, _HAWKBIT_APP_ (by default hawkbit-update-server), HAWKBIT_VERSION_ (by default the last released hawkBit version), _CONTAINER_PORT_ (by default 8080) on which the app opens the http server (if available) and (for mysql flavour only) _MARIADB_DRIVER_VERSION_ (by default 3.1.4 at the time of writing). -Both flavours of are almost the same, just mysql has in addition a MariaDB Java connector and is started, by default, with mysql Spring profile. - -## Build standard -Standard flavour could be build, for example, with: -```shell -docker build --build-arg HAWKBIT_APP=hawkbit-update-server -t hawkbit_update_server:0.3.0 . -f Dockerfile -``` -or just by: -```shell -docker build --build-arg HAWKBIT_APP=hawkbit-update-server -t hawkbit_update_server:0.3.0 . -``` -having that docker uses by default _Dockerfile_. - -## Build mysql -Mysql flavour could be build, for example, with: -```shell -docker build --build-arg HAWKBIT_APP=hawkbit-update-server -t hawkbit_update_server:0.3.0-mysql . -f Dockerfile-mysql -``` \ No newline at end of file