-
-
Save ochafik/2407a294e1bf46c0a7ec6368430eb5aa to your computer and use it in GitHub Desktop.
BridJ Docker cross-build image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -eu | |
| # Example: https://github.com/uraimo/run-on-arch-action | |
| # https://devopscube.com/run-docker-in-docker/#:~:text=To%20run%20docker%20inside%20docker,sock%20as%20a%20volume.&text=Just%20a%20word%20of%20caution,privileges%20over%20your%20docker%20daemon. | |
| # https://github.com/uraimo/run-on-arch-action/blob/master/src/run-on-arch.sh | |
| # --mount=type=cache,target=/root/.m2 | |
| docker build -t bridj-builder:latest -f- . <<EOF | |
| FROM debian:bullseye-slim | |
| LABEL maintainer="Olivier Chafik <olivier.chafik@gmail.com>" | |
| RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ | |
| --mount=type=cache,target=/var/lib/apt,sharing=locked \ | |
| apt-get update -qy && \ | |
| apt-get -qy full-upgrade && \ | |
| apt-get install -qy --no-install-recommends \ | |
| git mercurial ca-certificates vim maven cmake make gcc g++ openjdk-17-jdk \ | |
| qemu qemu-user-static \ | |
| curl && \ | |
| curl -sSL https://get.docker.com/ | sh | |
| ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk-amd64 | |
| # COPY run.sh / | |
| # COMMAND /run.sh | |
| WORKDIR /root | |
| EOF | |
| # CMD docker run --rm --privileged multiarch/qemu-user-static --reset -p yes --credential yes && /bin/bash | |
| export M2_DIR=$HOME/.m2 | |
| export BRIDJ_DIR=$PWD | |
| docker run \ | |
| -v /var/run/docker.sock:/var/run/docker.sock \ | |
| -v $M2_DIR:/root/.m2 \ | |
| -v $BRIDJ_DIR:/root/BridJ \ | |
| -e M2_DIR \ | |
| -e BRIDJ_DIR \ | |
| --rm -it bridj-builder:latest | |
| # bash -C "cd BridJ && ./BuildNative" | |
| mvn dependency:resolve | |
| # Enable QEMU for exotic platforms | |
| docker run --rm --privileged multiarch/qemu-user-static --reset -p yes --credential yes | |
| # Build a build environment on the fly and run the build script inside it | |
| docker run \ | |
| --platform linux/arm64 \ | |
| -v $M2_DIR:/root/.m2 \ | |
| -v $BRIDJ_DIR:/root/BridJ \ | |
| --rm -it $( echo " | |
| FROM arm64v8/debian:bullseye-slim | |
| RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ | |
| --mount=type=cache,target=/var/lib/apt,sharing=locked \ | |
| apt-get update -qy && \ | |
| apt-get -qy full-upgrade && \ | |
| apt-get install -qy --no-install-recommends \ | |
| git mercurial ca-certificates vim maven cmake make gcc g++ openjdk-17-jdk | |
| ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk-arm64 | |
| WORKDIR /root/BridJ | |
| " | docker build -f- . -q ) \ | |
| /bin/bash -c "FAST=1 ./BuildNative && mvn test" | |
| # --platform linux/386 ... i386/debian:bullseye-slim | |
| docker run --platform linux/arm64 --rm -v $BRIDJ_DIR:/root/BridJ -it arm64v8/debian:bullseye-slim | |
| "apt update && apt install -qy --no-install-recommends mercurial maven g++ vim cmake make openjdk-17-jdk" | |
| /bin/bash -c "FAST=1 ./BuildNative" | |
| docker run --platform linux/arm/v7 --rm -v $BRIDJ_DIR:/root/BridJ -it arm32v7/debian:bullseye-slim /bin/bash -c "cd /root/BridJ && ./BuildNative" | |
| docker run --platform linux/arm/v6 --rm -v $BRIDJ_DIR:/root/BridJ -it balenalib/rpi-raspbian:bullseye-slim /bin/bash -c "cd /root/BridJ && ./BuildNative" | |
| # aarch64: arm64v8/debian:bullseye-slim | |
| # armv7: arm32v7/debian:bullseye-slim | |
| # armv6: balenalib/rpi-raspbian:bullseye-slim | |
| git clone --depth=1 https://github.com/nativelibs4java/BridJ -b refresh-2022 && \ | |
| cd BridJ && \ | |
| ./BuildNative |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment