From f7a45f9d10b54d32c4a3794c954b2d402d94fd4e Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Thu, 20 Aug 2020 09:27:54 +1000 Subject: [PATCH] Cross compile for armv7/armv8, raise raspi variant to armv6 (only) (#737) * Add arm cross compile changes from #602 * Bump pi arm version * Prevent caching of yarn key * Add dockerignore for build dockerfile --- .dockerignore | 63 ++++++++++++++++++++++++++++++++++ .travis.yml | 6 +++- docker/build/x86_64/Dockerfile | 8 +++-- docker/compiler/Dockerfile | 9 +++-- docker/compiler/Makefile | 4 +-- scripts/cross-compile.sh | 12 ++++--- 6 files changed, 90 insertions(+), 12 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..990c8acd4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,63 @@ +#### +# Go +#### + +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Packr2 artifacts +**/*-packr.go + +# GraphQL generated output +pkg/models/generated_*.go +ui/v2.5/src/core/generated-*.tsx + +# packr generated files +*-packr.go + +#### +# Jetbrains +#### + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +#### +# Random +#### + +ui/v2.5/node_modules +ui/v2.5/build + +*.db + +stash +dist + +docker \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 1f9876c3c..79e7995e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,6 +44,8 @@ deploy: - dist/stash-osx - dist/stash-win.exe - dist/stash-linux + - dist/stash-linux-arm64v8 + - dist/stash-linux-arm32v7 - dist/stash-pi skip_cleanup: true overwrite: true @@ -61,12 +63,14 @@ deploy: - dist/stash-osx - dist/stash-win.exe - dist/stash-linux + - dist/stash-linux-arm64v8 + - dist/stash-linux-arm32v7 - dist/stash-pi # make the release a draft so the maintainers can confirm before releasing draft: true skip_cleanup: true overwrite: true - # don't write the body. To be done manually for now. In future we might + # don't write the body. To be done manually for now. In future we might # want to generate the changelog or get it from a file name: ${STASH_VERSION} on: diff --git a/docker/build/x86_64/Dockerfile b/docker/build/x86_64/Dockerfile index 8ac117647..54fed78f9 100644 --- a/docker/build/x86_64/Dockerfile +++ b/docker/build/x86_64/Dockerfile @@ -6,8 +6,12 @@ FROM golang:1.11.13 as compiler RUN apt-get update && apt-get install -y apt-transport-https RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - -RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list + +# prevent caching of the key +ADD https://dl.yarnpkg.com/debian/pubkey.gpg yarn.gpg +RUN cat yarn.gpg | apt-key add - && \ + echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ + rm yarn.gpg RUN apt-get update && \ apt-get install -y nodejs yarn xz-utils --no-install-recommends || exit 1; \ diff --git a/docker/compiler/Dockerfile b/docker/compiler/Dockerfile index 1a0126979..09c1ffd08 100644 --- a/docker/compiler/Dockerfile +++ b/docker/compiler/Dockerfile @@ -10,9 +10,12 @@ ENV PACKR2_DOWNLOAD_URL=https://github.com/gobuffalo/packr/releases/download/v${ # Install tools RUN apt-get update && apt-get install -y apt-transport-https RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - -RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list +# prevent caching of the key +ADD https://dl.yarnpkg.com/debian/pubkey.gpg yarn.gpg +RUN cat yarn.gpg | apt-key add - && \ + echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ + rm yarn.gpg RUN apt-get update && \ apt-get install -y automake autogen \ @@ -20,6 +23,8 @@ RUN apt-get update && \ patch make tar xz-utils bzip2 gzip sed cpio \ gcc-6-multilib g++-6-multilib gcc-mingw-w64 g++-mingw-w64 clang llvm-dev \ gcc-arm-linux-gnueabi libc-dev-armel-cross linux-libc-dev-armel-cross \ + gcc-arm-linux-gnueabihf libc-dev-armhf-cross \ + gcc-aarch64-linux-gnu libc-dev-arm64-cross \ nodejs yarn --no-install-recommends || exit 1; \ rm -rf /var/lib/apt/lists/*; diff --git a/docker/compiler/Makefile b/docker/compiler/Makefile index 278130e0f..c705b1b6f 100644 --- a/docker/compiler/Makefile +++ b/docker/compiler/Makefile @@ -1,6 +1,6 @@ -user=stashappdev +user=stashapp repo=compiler -version=2 +version=3 latest: docker build -t ${user}/${repo}:latest . diff --git a/scripts/cross-compile.sh b/scripts/cross-compile.sh index d6d16e9f1..37e1f3bad 100755 --- a/scripts/cross-compile.sh +++ b/scripts/cross-compile.sh @@ -4,12 +4,14 @@ BUILD_DATE=`go run -mod=vendor scripts/getDate.go` GITHASH=`git rev-parse --short HEAD` STASH_VERSION=`git describe --tags --exclude latest_develop` SETENV="BUILD_DATE=\"$BUILD_DATE\" GITHASH=$GITHASH STASH_VERSION=\"$STASH_VERSION\"" -SETUP="export GO111MODULE=on; export CGO_ENABLED=1; make packr;" +SETUP="export GO111MODULE=on; export CGO_ENABLED=1; set -e; echo '=== Running packr ==='; make packr;" WINDOWS="echo '=== Building Windows binary ==='; $SETENV GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ LDFLAGS=\"-extldflags '-static' \" OUTPUT=\"dist/stash-win.exe\" make build-release;" DARWIN="echo '=== Building OSX binary ==='; $SETENV GOOS=darwin GOARCH=amd64 CC=o64-clang CXX=o64-clang++ OUTPUT=\"dist/stash-osx\" make build-release;" -LINUX="echo '=== Building Linux binary ==='; $SETENV OUTPUT=\"dist/stash-linux\" make build-release;" -RASPPI="echo '=== Building Raspberry Pi binary ==='; $SETENV GOOS=linux GOARCH=arm GOARM=5 CC=arm-linux-gnueabi-gcc OUTPUT=\"dist/stash-pi\" make build-release;" +LINUX_AMD64="echo '=== Building Linux (amd64) binary ==='; $SETENV GOOS=linux GOARCH=amd64 OUTPUT=\"dist/stash-linux\" make build-release;" +LINUX_ARM64v8="echo '=== Building Linux (armv8/arm64) binary ==='; $SETENV GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc OUTPUT=\"dist/stash-linux-arm64v8\" make build-release;" +LINUX_ARM32v7="echo '=== Building Linux (armv7/armhf) binary ==='; $SETENV GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabihf-gcc OUTPUT=\"dist/stash-linux-arm32v7\" make build-release;" +LINUX_ARM32v6="echo '=== Building Linux (armv6 | Raspberry Pi 1) binary ==='; $SETENV GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc OUTPUT=\"dist/stash-pi\" make build-release;" -COMMAND="$SETUP $WINDOWS $DARWIN $LINUX $RASPPI" +COMMAND="$SETUP $WINDOWS $DARWIN $LINUX_AMD64 $LINUX_ARM64v8 $LINUX_ARM32v7 $LINUX_ARM32v6 echo '=== Build complete ==='" -docker run --rm --mount type=bind,source="$(pwd)",target=/stash -w /stash stashapp/compiler:develop /bin/bash -c "$COMMAND" +docker run --rm --mount type=bind,source="$(pwd)",target=/stash -w /stash stashapp/compiler:latest /bin/bash -c "$COMMAND"