diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml index a2b855b4..9cc47154 100644 --- a/.github/workflows/server.yml +++ b/.github/workflows/server.yml @@ -89,6 +89,81 @@ jobs: name: Webui path: webui/dist + build-native-libs: + strategy: + matrix: + os: + - ubuntu-latest + - macos-latest + + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: "21" + distribution: "zulu" + cache: maven + + - name: Cmake build + run: | + cmake -B"build" -S"libdhfs_support" -DDHFS_LIB_INSTALL="result" + cmake --build build --target install + + - name: Upload build + uses: actions/upload-artifact@v3 + with: + name: NativeLib-${{ matrix.os }} + path: result + + build-native-libs-docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: build + run: | + CROSS_PLATFORM="linux/arm64" libdhfs_support/builder/cross-build.sh both build result + + - name: Upload build + uses: actions/upload-artifact@v3 + with: + name: NativeLib-${{ matrix.os }} + path: result + + merge-native-libs: + runs-on: ubuntu-latest + needs: [build-native-libs, build-native-libs-docker] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + path: downloaded-libs + + - name: Merge + run: rsync -av downloaded-libs/NativeLib*/* result/ + + - name: Check paths + run: | + test -f "result/Linux-x86_64/libdhfs_support.so" || exit 1 + + - uses: actions/upload-artifact@v3 + with: + name: NativeLibs + path: result + publish-docker: runs-on: ubuntu-latest permissions: @@ -98,7 +173,7 @@ jobs: # with sigstore/fulcio when running outside of PRs. id-token: write - needs: [build-webui, build-dhfs] + needs: [build-webui, merge-native-libs, build-dhfs] steps: - name: Checkout repository @@ -114,6 +189,11 @@ jobs: name: Webui path: webui-dist-downloaded + - uses: actions/download-artifact@v3 + with: + name: NativeLibs + path: dhfs-native-downloaded + - name: Show all the files run: find . @@ -189,7 +269,7 @@ jobs: # with sigstore/fulcio when running outside of PRs. id-token: write - needs: [build-webui, build-dhfs] + needs: [build-webui, merge-native-libs, build-dhfs] steps: - name: Checkout repository @@ -205,6 +285,11 @@ jobs: name: Webui path: webui-dist-downloaded + - uses: actions/download-artifact@v3 + with: + name: NativeLibs + path: dhfs-native-downloaded + - name: Show all the files run: find . @@ -217,6 +302,9 @@ jobs: - name: Copy Webui run: cp -r ./webui-dist-downloaded "run-wrapper-out/dhfs/app/Webui" + - name: Copy Webui + run: cp -r ./dhfs-native-downloaded "run-wrapper-out/dhfs/app/NativeLibs" + - name: Copy run wrapper run: cp -r ./run-wrapper/* "run-wrapper-out/dhfs/app/" diff --git a/Dockerfile b/Dockerfile index acdfb220..d24b7a13 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ COPY ./server/mvnw ./server/pom.xml ./ RUN ./mvnw quarkus:go-offline # The previous thing still doesn't download 100% everything RUN ./mvnw -Dmaven.test.skip=true -Dskip.unit=true package --fail-never -COPY ./server/. . +COPY ./server/. . RUN ./mvnw -Dmaven.test.skip=true -Dskip.unit=true clean package FROM azul/zulu-openjdk-alpine:21-jre-headless diff --git a/Dockerfile.ci b/Dockerfile.ci index 7afa0a47..772fbad9 100644 --- a/Dockerfile.ci +++ b/Dockerfile.ci @@ -4,11 +4,14 @@ RUN apk update && apk add fuse && rm -rf /var/cache/apk/* WORKDIR /usr/src/app COPY ./dhfs-package-downloaded/. . -RUN mkdir -p webui -COPY ./webui-dist-downloaded/. ./webui +WORKDIR /usr/src/app/native-libs +COPY ./dhfs-native-downloaded/. . +WORKDIR /usr/src/app/webui +COPY ./webui-dist-downloaded/. . ENV dhfs_webui_root=/usr/src/app/webui +WORKDIR /usr/src/app COPY ./dockerentry.sh . RUN ["chmod", "+x", "./dockerentry.sh"] diff --git a/libdhfs_support/builder/cross-build.sh b/libdhfs_support/builder/cross-build.sh index 90f7a2ff..b4208feb 100755 --- a/libdhfs_support/builder/cross-build.sh +++ b/libdhfs_support/builder/cross-build.sh @@ -4,20 +4,20 @@ export SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd cd "$SCRIPT_DIR" if [[ -z "${INSIDE_DOCKER_ALREADY}" ]]; then - if [[ "$(uname)" == "Linux" ]] - then - echo "Already on linux" - exit 0 + if [[ "$(uname)" == "Linux" ]]; then + if [[ -z "${CROSS_PLATFORM}" ]]; then + echo "Already on linux" + exit 0 + fi fi exec "$SCRIPT_DIR"/docker-launch.sh "$@" fi set -euxo pipefail -if [ $# -lt 3 ] - then - echo "Not enough arguments supplied: (build/configure) (build dir) (output dir)" - exit 1 +if [ $# -lt 3 ]; then + echo "Not enough arguments supplied: (build/configure) (build dir) (output dir)" + exit 1 fi PROJECT_DIR="$SCRIPT_DIR/.." @@ -37,14 +37,18 @@ mkdir -p "$2" mkdir -p "$3" case "$1" in - "configure") - configure - ;; - "build") - build - ;; - *) - echo "Unknown command" - exit 1 - ;; +"configure") + configure + ;; +"build") + build + ;; +"both") + configure + build + ;; +*) + echo "Unknown command" + exit 1 + ;; esac diff --git a/libdhfs_support/builder/docker-launch.sh b/libdhfs_support/builder/docker-launch.sh index 59be4493..5c6818c9 100755 --- a/libdhfs_support/builder/docker-launch.sh +++ b/libdhfs_support/builder/docker-launch.sh @@ -1,5 +1,10 @@ #!/usr/bin/env bash +PLATFORM_ARG="" +if [[ ! -z "${CROSS_PLATFORM}" ]]; then + PLATFORM_ARG="--platform $CROSS_PLATFORM" +fi + set -euxo pipefail export SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) cd "$SCRIPT_DIR" @@ -9,5 +14,5 @@ docker build --iidfile "$DOCKER_IMG_FILE" . ROOT_DIR="$(dirname "$(dirname "$SCRIPT_DIR")")" -docker run --rm -v "$ROOT_DIR:$ROOT_DIR" -e INSIDE_DOCKER_ALREADY=TRUE "$(cat "$DOCKER_IMG_FILE")" \ - "$SCRIPT_DIR/cross-build.sh" "$@" \ No newline at end of file +docker run --rm -v "$ROOT_DIR:$ROOT_DIR" -e INSIDE_DOCKER_ALREADY=TRUE "$(cat "$DOCKER_IMG_FILE")" \ + "$SCRIPT_DIR/cross-build.sh" "$@" diff --git a/run-wrapper/run b/run-wrapper/run index 9d37b366..ae267ef0 100755 --- a/run-wrapper/run +++ b/run-wrapper/run @@ -35,6 +35,7 @@ java \ -Dquarkus.http.host=0.0.0.0 \ -Ddhfs.objects.ref_verification=false \ -Dquarkus.log.category.\"com.usatiuk.dhfs\".level=INFO \ + -Dcom.usatiuk.dhfs.supportlib.native-path="$SCRIPT_DIR"/NativeLibs \ -Ddhfs.webui.root="$SCRIPT_DIR"/Webui $EXTRAOPTS_PARSED \ -jar "$SCRIPT_DIR"/"DHFS Package"/quarkus-run.jar >quarkus.log 2>&1 &