diff --git a/.containerversion b/.containerversion index 9902f17848..f04c001f3f 100644 --- a/.containerversion +++ b/.containerversion @@ -1 +1 @@ -28 +29 diff --git a/Dockerfile b/Dockerfile index fed49e6e4f..afcee3b9fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,25 +11,21 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -FROM thyrlian/android-sdk:4.0 as android +FROM thyrlian/android-sdk:4.0 AS android FROM ubuntu:22.04 -ENV DEBIAN_FRONTEND noninteractive - # Android COPY --from=android /opt/android-sdk /opt/android-sdk -ADD scripts/docker_install.sh /tmp/ -RUN /tmp/docker_install.sh +RUN --mount=target=/mnt,source=scripts DEBIAN_FRONTEND=noninteractive /mnt/docker_install.sh -ENV GOPATH /opt/go -ENV GOROOT /opt/go_dist/go -ENV PATH $GOROOT/bin:$GOPATH/bin:$PATH +# In this path executables will be installed during docker build +ARG SYS_GOPATH=/opt/go +ENV PATH=${SYS_GOPATH}/bin:/usr/local/go/bin:$PATH -ADD Makefile /tmp/ -RUN make -C /tmp/ envinit +RUN --mount=target=/mnt/Makefile,source=Makefile GOPATH=${SYS_GOPATH} make -C /mnt envinit -ENV PATH /opt/qt6/6.8.2/gcc_64/bin:/opt/qt6/6.8.2/gcc_64/libexec:$PATH +ENV PATH=/opt/qt6/6.8.2/gcc_64/bin:/opt/qt6/6.8.2/gcc_64/libexec:$PATH CMD ["bash"] diff --git a/Makefile b/Makefile index 6b8a04b6f7..40f675f02b 100644 --- a/Makefile +++ b/Makefile @@ -14,14 +14,12 @@ SHELL := /bin/bash WEBROOT := frontends/web -GOPATH ?= $(HOME)/go -PATH := $(PATH):$(GOPATH)/bin catch: @echo "Choose a make target." envinit: # Keep golangci-lint version in sync with what's in .github/workflows/ci.yml. - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.61.0 + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.61.0 go install github.com/vektra/mockery/v2@v2.46.0 go install github.com/matryer/moq@v0.4.0 go install golang.org/x/tools/cmd/goimports@latest @@ -84,8 +82,11 @@ clean: cd frontends/qt && $(MAKE) clean cd frontends/android && $(MAKE) clean cd backend/mobileserver && $(MAKE) clean + +# The container image only supports amd64 bercause of "thyrlian/android-sdk" +# that downloads amd64 specific binaries dockerinit: - ./scripts/container.sh build --pull --force-rm -t shiftcrypto/bitbox-wallet-app . + ./scripts/container.sh build --platform linux/amd64 --pull -t shiftcrypto/bitbox-wallet-app:$(shell cat .containerversion) . dockerdev: ./scripts/dockerdev.sh locize-push: diff --git a/android-env.mk.inc b/android-env.mk.inc index 925a05492e..a10f3c887f 100644 --- a/android-env.mk.inc +++ b/android-env.mk.inc @@ -1,4 +1,2 @@ export ANDROID_SDK_ROOT := /opt/android-sdk export ANDROID_NDK_HOME := /opt/android-sdk/ndk/21.2.6472646 -# gomodcache location for gomobile build pkgs. Set to tmp folder, because writing access is needed. -export GOMODCACHE_ROOT := /tmp/gomodcache/pkg/mod diff --git a/backend/mobileserver/Makefile b/backend/mobileserver/Makefile index d5afed7786..aaf1c0526b 100644 --- a/backend/mobileserver/Makefile +++ b/backend/mobileserver/Makefile @@ -1,10 +1,9 @@ include ../../android-env.mk.inc -# GOMODCACHE to /tmp directory, because gomobile needs to write pkgs. -# Also set -glflags to fix the vendor issue with gomobile, see: https://github.com/golang/go/issues/67927#issuecomment-2241523694 +# Set -glflags to fix the vendor issue with gomobile, see: https://github.com/golang/go/issues/67927#issuecomment-2241523694 build-android: - GOMODCACHE=${GOMODCACHE_ROOT} ANDROID_HOME=${ANDROID_SDK_ROOT} gomobile bind -x -a -glflags="-mod=readonly" -ldflags="-s -w" -target android . + ANDROID_HOME=${ANDROID_SDK_ROOT} gomobile bind -x -a -glflags="-mod=readonly" -ldflags="-s -w" -target android . build-ios: - GOMODCACHE=${GOMODCACHE_ROOT} gomobile bind -x -a -glflags="-mod=readonly" -ldflags="-s -w" -target ios,iossimulator . + gomobile bind -x -a -glflags="-mod=readonly" -ldflags="-s -w" -target ios,iossimulator . clean: rm -f mobileserver.aar mobileserver-sources.jar diff --git a/scripts/docker_install.sh b/scripts/docker_install.sh index c63321b6ca..14e1553a40 100755 --- a/scripts/docker_install.sh +++ b/scripts/docker_install.sh @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. - apt-get update apt-get install -y --no-install-recommends curl ca-certificates @@ -83,8 +82,7 @@ aqt install-qt linux desktop 6.8.2 -m qtpositioning qtserialport qtwebchannel qt npm install -g npm@10 npm install -g locize-cli -mkdir -p /opt/go_dist -curl https://dl.google.com/go/go1.22.5.linux-amd64.tar.gz | tar -xz -C /opt/go_dist +curl https://dl.google.com/go/go1.22.5.linux-amd64.tar.gz | tar -xz -C /usr/local # fuse is needed to run the linuxdeployqt appimage. apt-get install -y --no-install-recommends fuse diff --git a/scripts/github-ci.sh b/scripts/github-ci.sh index 8b0f702206..6b3a330374 100755 --- a/scripts/github-ci.sh +++ b/scripts/github-ci.sh @@ -12,7 +12,7 @@ if [ "$OS_NAME" == "linux" ]; then # Which docker image to use to run the CI. Defaults to Docker Hub. # Overwrite with CI_IMAGE=docker/image/path environment variable. # Keep this in sync with .github/workflows/ci.yml. - : "${CI_IMAGE:=shiftcrypto/bitbox-wallet-app:26}" + : "${CI_IMAGE:=shiftcrypto/bitbox-wallet-app:$(cat .containerversion)}" # Time image pull to compare in the future. time docker pull "$CI_IMAGE" @@ -22,9 +22,9 @@ if [ "$OS_NAME" == "linux" ]; then # CI (https://github.com/actions/checkout/issues/760) docker run --privileged \ -v $HOME/.gradle:/root/.gradle \ - -v ${GITHUB_BUILD_DIR}:/opt/go/${GO_SRC_DIR}/ \ + -v ${GITHUB_BUILD_DIR}:/root/go/${GO_SRC_DIR}/ \ -i "${CI_IMAGE}" \ - bash -c "git config --global --add safe.directory \$GOPATH/${GO_SRC_DIR} && make -C \$GOPATH/${GO_SRC_DIR} ${WHAT}" + bash -c "git config --global --add safe.directory \$(go env GOPATH)/${GO_SRC_DIR} && make -C \$(go env GOPATH)/${GO_SRC_DIR} ${WHAT}" fi # The following is executed only on macOS machines. @@ -32,14 +32,8 @@ if [ "$OS_NAME" == "osx" ]; then # GitHub CI installs Go and Qt directly in the macos action, before executing # this script. go version - export GOPATH=~/go - export PATH="$PATH:~/go/bin" - mkdir -p $GOPATH/$(dirname $GO_SRC_DIR) - # GitHub checkout action (git clone) seem to require current work dir - # to be the root of the repo during its clean up phase. So, we push it - # here and pop in the end. - pushd ../ && cp -a bitbox-wallet-app $GOPATH/$(dirname $GO_SRC_DIR) - cd $GOPATH/$GO_SRC_DIR - make "$WHAT" - popd + export PATH="~/go/bin:$PATH" + mkdir -p $(go env GOPATH)/$(dirname $GO_SRC_DIR) + cp -a ../bitbox-wallet-app $(go env GOPATH)/$(dirname $GO_SRC_DIR) + make -C $(go env GOPATH)/$GO_SRC_DIR "$WHAT" fi