From ddd06af9b224aee671e3fac8c3a6b7e444b48a97 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Sun, 3 Mar 2024 11:06:39 -0800 Subject: [PATCH] consolidation into go-cross-compile --- Dockerfile | 37 ++++++++++++++++++++++++------------- README.md | 53 +++++++++++------------------------------------------ 2 files changed, 35 insertions(+), 55 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8780fc7..419ef7a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,28 @@ +# Ubuntu 20.04 for that slightly older and more compat glibc +FROM eclipse-temurin:8-jdk-focal + + +# compile tools we need including for cross compiling to windows and arm8 +# also ssl certs, ssh, and jq for deployment related tasks +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + bash \ + build-essential \ + openssl \ + libssl-dev \ + git \ + wget \ + unzip \ + netcat git wget libc6-dev make gcc g++ pkg-config g\+\+-mingw-w64 \ + gcc-aarch64-linux-gnu \ + jq openssh-client ca-certificates curl \ + ; \ + rm -rf /var/lib/apt/lists/*; + + # Android section of this Dockerfile from https://medium.com/@elye.project/intro-to-docker-building-android-app-cb7fb1b97602 -FROM openjdk:8 - - ENV SDK_URL="https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip" \ ANDROID_HOME="/usr/local/android-sdk" \ ANDROID_SDK=$ANDROID_HOME \ @@ -10,7 +30,7 @@ ENV SDK_URL="https://dl.google.com/android/repository/sdk-tools-linux-4333796.zi ANDROID_BUILD_TOOLS_VERSION=30.0.2 ## Download Android SDK -RUN mkdir "$ANDROID_HOME" .android \ +RUN mkdir -p "$ANDROID_HOME" .android \ && cd "$ANDROID_HOME" \ && curl -o sdk.zip $SDK_URL \ && unzip sdk.zip \ @@ -40,15 +60,6 @@ ENV GOLANG_VERSION=1.21.5.linux-amd64 ENV GOLANG_SHA256=e2bc0b3e4b64111ec117295c088bde5f00eeed1567999ff77bc859d7df70078e RUN set -eux; \ - apt-get update; \ - apt-get install -y --no-install-recommends \ - bash \ - build-essential \ - openssl \ - libssl-dev \ - golang \ - ; \ - rm -rf /var/lib/apt/lists/*; \ wget -O go.tgz "https://golang.org/dl/go$GOLANG_VERSION.tar.gz"; \ echo "$GOLANG_SHA256 *go.tgz" | sha256sum -c -; \ tar -C /usr/local -xzf go.tgz; \ diff --git a/README.md b/README.md index ebcdc53..51554ff 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,35 @@ -# Android, Go, and gomobile +# Open Privacy's Go Cross Compile Container -Dockerfiles @ [git.openprivacy.ca/openprivacy/android-go-mobile](https://git.openprivacy.ca/openprivacy/android-go-mobile) +Dockerfiles @ [git.openprivacy.ca/openprivacy/go-cross-compile](https://git.openprivacy.ca/openprivacy/go-cross-compile) This image was built for use with Drone CI but can be used with any docker setup you want. Versions are: -- 2024.01 +- 2024.02 - Go 1.21.5 + - glibc 2.31 from Ubuntu 20.04 - Android API 31 - - NDK 21.0.6113669 -- 2022.11 - - Go 1.19.3 - - Android API 31 - - NDK 21.0.6113669 -- 2021.03 - - Go 1.17.5 - - Android API 30 - - NDK 21.0.6113669 -- 2021.03 - - Go 1.15.10 - - Android API 29 - - NDK 21.0.6113669 -- 2018.07 - - Go 1.10.3 - - Android API 28 - - NDK 17.2.4988734 + - NDK 22.1.7171670 + - arm8 gcc cross compiler + - mingw windows cross compiler ## Install and Use -### Version 2021.03 +### Version 2024.02 This image includes: -- Android SDK, NDK, tools, and API version 29 and Buildtools 30.0.2 at `/usr/local/android-sdk` -- Go lang 1.15.10 at `/usr/local/go` +- Android SDK, NDK, tools, and API version 31 and Buildtools 30.0.2 at `/usr/local/android-sdk` +- Go lang at `/usr/local/go` - $GOPATH set to `/gomobile` - GOPATH includes gomobile cmd tools and source This container has its own GOPATH with only gomobile in it, so to use, you'll need to re-get your go dependancies and then run `gomobile init`. The following example shows a Drone CI step using this image gomobile-build: - image: openpriv/android-go-mobile:2021.03 + image: openpriv/go-cross-compile:2024.02 commands: - go mod download - gomobile init - make - -### Version 2018.07 - -This image includes: - -- Android SDK, NDK, tools, and API version 28 at `/usr/local/android-sdk` -- Go lang 1.10.3 at `/usr/local/go` -- $GOPATH set to `/workspace/go` -- A go directory with an initialized gomobile installed at `/go` - -This image comes with gomobile checkedout and preinitialized (time and space consuming). In order to install this predone work from the image into your Drone CI workspace (a docker volume mounted to `/workspace`), you will want your first pipeline step to be: - - go-link: - image: openpriv/android-go-mobile - commands: - - cp -as /go /workspace/go - -`cp -as` recreates the directory structure from /go in /workspace/go but for each file, it just creates a symlink. This is the quickest and most efficent way to mirror the work supplied with the image into your workspace.