diff --git a/.gitignore b/.gitignore index 80b802a2..b4f81f33 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,8 @@ go.work go.work.sum zrok-venv +# cache used by local dev cross-build script +/.npm npm-debug.log* yarn-debug.log* yarn-error.log* diff --git a/docker/images/cross-build/Dockerfile b/docker/images/cross-build/Dockerfile index 4670025f..2f5f0670 100644 --- a/docker/images/cross-build/Dockerfile +++ b/docker/images/cross-build/Dockerfile @@ -1,3 +1,4 @@ +# Stage 1: Install Node.js with nvm FROM debian:bullseye-slim # # this file mirrors the build params used in the GitHub Actions and enables @@ -12,23 +13,31 @@ ARG go_root=/usr/local/go ARG go_cache=/usr/share/go_cache ARG uid=1000 ARG gid=1000 -RUN apt-get -y update -RUN apt-get -y install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf gcc-aarch64-linux-gnu -RUN apt-get -y install wget build-essential +RUN apt-get -y update \ + && apt-get -y install \ + gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf gcc-aarch64-linux-gnu \ + wget build-essential -COPY ./linux-build.sh /usr/local/bin/ RUN wget -q https://go.dev/dl/${go_distribution_file} RUN tar -xzf ${go_distribution_file} -C /usr/local/ +RUN wget -qO- https://deb.nodesource.com/setup_18.x | bash \ + && apt-get -y update \ + && apt-get -y install \ + nodejs + RUN mkdir ${go_path} ${go_cache} RUN chown -R ${uid}:${gid} ${go_path} ${go_cache} +COPY ./linux-build.sh /usr/local/bin/ + USER ${uid}:${gid} ENV TARGETARCH=${TARGETARCH} ENV GOPATH=${go_path} ENV GOROOT=${go_root} ENV GOCACHE=${go_cache} ENV PATH=${go_path}/bin:${go_root}/bin:$PATH + RUN go install github.com/mitchellh/gox@latest WORKDIR /mnt ENTRYPOINT ["linux-build.sh"] diff --git a/docker/images/cross-build/linux-build.sh b/docker/images/cross-build/linux-build.sh index 9d31a8ff..447106a8 100755 --- a/docker/images/cross-build/linux-build.sh +++ b/docker/images/cross-build/linux-build.sh @@ -6,7 +6,10 @@ # # -set -o pipefail -e -u +set -o errexit +set -o nounset +set -o pipefail +set -o xtrace # if no architectures supplied then default list of three if (( ${#} )); then @@ -31,6 +34,16 @@ else PROCS_PER_JOB=0 # invokes gox default to use all CPUs-1 fi +( + HOME=/tmp/builder + # Navigate to the "ui" directory and run npm commands + npm config set cache /mnt/.npm + cd ./ui/ + mkdir -p $HOME + npm install + npm run build +) + for ARCH in ${JOBS[@]}; do GOX_CMD=" gox \