taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

Containerfile (10614B)


      1 FROM docker.io/library/debian:trixie
      2 
      3 ENV DEBIAN_FRONTEND=noninteractive
      4 ENV LANG=C.UTF-8
      5 ENV ANDROID_HOME=/opt/android-sdk
      6 # The JDK is trixie's own OpenJDK 21 (the distribution packages 21 and 25, not
      7 # 17).  That is only the JVM that *runs* Gradle: every Kotlin module pins
      8 # `jvmTarget = "17"` and `compileOptions` to `VERSION_17`, and
      9 # donau-verificator is plain Java with the same `compileOptions`, so the
     10 # bytecode the apps ship does not depend on this choice.  Verified by running
     11 # `./gradlew check` over all six modules on JDK 17 and on JDK 21 with the
     12 # repository's own Gradle 9.4.1 / AGP 9.2.1 / Kotlin 2.3.21: 435 unit tests,
     13 # no failures, byte-for-byte the same task outcomes.  21 over 25 because
     14 # Robolectric documents 21 and 25 is not yet exercised here.
     15 ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
     16 ENV PATH="${PATH}:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools:/root/.local/bin"
     17 
     18 # Base tools: what the jobs themselves shell out to, plus fdroidserver's and
     19 # the coverage job's Python.  procps is for the emulator teardown: emu.sh
     20 # falls back to `pgrep -f -- "-port <console>"` when `adb emu kill` leaves the
     21 # process behind, and without it that fallback fails with "pgrep: command not
     22 # found" -- quietly, because the teardown is deliberately non-fatal.  An
     23 # emulator that survives a job keeps its AVD lock files and the *next* run
     24 # fails to boot on them.
     25 RUN apt-get update && apt-get -qy install --no-install-recommends \
     26     bash \
     27     ca-certificates \
     28     curl \
     29     git \
     30     openssh-client \
     31     pipx \
     32     procps \
     33     python3 \
     34     python3-pip \
     35     python3-setuptools \
     36     python3-wheel \
     37     rsync \
     38     unzip \
     39  && rm -rf /var/lib/apt/lists/*
     40 
     41 # The JDK, from Debian itself rather than a third-party archive.  The
     42 # -headless package is enough: Gradle, the Kotlin compiler, Android lint and
     43 # apksigner all run without AWT, which the verification runs confirmed.
     44 # JAVA_HOME is asserted rather than assumed, so a package that ever lands
     45 # somewhere else stops the build here instead of handing every later Gradle
     46 # invocation a JAVA_HOME that does not exist.
     47 RUN apt-get update \
     48  && apt-get -qy install --no-install-recommends openjdk-21-jdk-headless \
     49  && rm -rf /var/lib/apt/lists/* \
     50  && test -x "${JAVA_HOME}/bin/javac" \
     51  && "${JAVA_HOME}/bin/java" -version
     52 
     53 # GNU Taler's own binaries, for the jobs that drive the apps rather than
     54 # compile them: taler-wallet-cli is the headless wallet the integration suites
     55 # pay and withdraw with, taler-twister the proxy they damage protocol replies
     56 # with to reach the error paths.  `trixie-testing` rather than `trixie`
     57 # because it tracks the protocol version the apps in this repository are
     58 # written against.
     59 #
     60 # The signing key is pinned by digest -- it is fetched over HTTPS at build
     61 # time, and the hash is the one shipped in bfh-infra's taler_apt role, so a
     62 # substituted key fails the build rather than silently signing a different
     63 # archive.
     64 RUN curl -fsSL -o /etc/apt/keyrings/taler-systems.gpg \
     65          https://www.taler.net/taler-systems.gpg \
     66  && echo "173823431a6bdaf06d315cd86b2c50937eafac986eb8f127b2953210fba6b79c  /etc/apt/keyrings/taler-systems.gpg" \
     67          | sha256sum -c - \
     68  && echo "deb [signed-by=/etc/apt/keyrings/taler-systems.gpg arch=amd64] https://deb.taler.net/apt/debian trixie-testing main" \
     69          > /etc/apt/sources.list.d/taler.list \
     70  && apt-get update \
     71  && apt-get -qy install --no-install-recommends \
     72     taler-twister \
     73     taler-wallet-cli \
     74  && rm -rf /var/lib/apt/lists/* \
     75  && command -v taler-twister \
     76  && command -v taler-wallet-cli
     77 
     78 # The Android command-line tools, pinned and checksummed.  Google serves only
     79 # a `_latest` URL per revision, so the digest is what actually fixes the
     80 # version; bump both together.
     81 RUN set -eu; \
     82     zip=commandlinetools-linux-13114758_latest.zip; \
     83     cd /tmp; \
     84     curl -fsSLO "https://dl.google.com/android/repository/${zip}"; \
     85     echo "7ec965280a073311c339e571cd5de778b9975026cfcbe79f2b1cdcb1e15317ee  ${zip}" | sha256sum -c -; \
     86     unzip -q "${zip}"; \
     87     mkdir -p "${ANDROID_HOME}/cmdline-tools"; \
     88     mv cmdline-tools "${ANDROID_HOME}/cmdline-tools/latest"; \
     89     rm -f "${zip}"; \
     90     sdkmanager --version
     91 
     92 # Licences first, so every later sdkmanager call is non-interactive, then the
     93 # platforms the briar image used to carry.  compileSdk 37 is deliberately not
     94 # installed: Google publishes it only as minor versions (android-37.0, .1,
     95 # .2), and AGP already downloads the exact platform a module asks for, which
     96 # is how the previous base -- which stopped at android-36 -- built this
     97 # repository.
     98 RUN yes | sdkmanager --licenses > /dev/null
     99 RUN sdkmanager \
    100     "platform-tools" \
    101     "platforms;android-34" \
    102     "platforms;android-35" \
    103     "platforms;android-36" \
    104     "build-tools;35.0.0" \
    105  && ln -s "${ANDROID_HOME}/build-tools/35.0.0/apksigner" /usr/bin/ \
    106  && ln -s "${ANDROID_HOME}/build-tools/35.0.0/aapt2"     /usr/bin/
    107 
    108 # The Android emulator, for the jobs that drive an app rather than compile it.
    109 #
    110 # It costs roughly 1.5 GB in an image every job pulls; one big image was the
    111 # deliberate choice over a second one, because a per-job Containerfile is not
    112 # something the buildbot supports (its generic stage step passes only jobCmd,
    113 # never containerFile).
    114 #
    115 # The emulator binary is dynamically linked against X and friends even when it
    116 # is run with -no-window.  Without them it dies with
    117 #
    118 #     libX11.so.6: cannot open shared object file: No such file or directory
    119 #
    120 # which reads like a broken SDK rather than a missing dependency, so the list
    121 # is spelled out.  libasound2 was renamed libasound2t64 in trixie; the
    122 # fallback keeps the build working whenever the base image moves again.
    123 RUN apt-get update && apt-get -qy install --no-install-recommends \
    124     fontconfig \
    125     libdrm2 \
    126     libgbm1 \
    127     libgl1 \
    128     libglu1-mesa \
    129     libnspr4 \
    130     libnss3 \
    131     libpulse0 \
    132     libx11-6 \
    133     libxcb1 \
    134     libxcomposite1 \
    135     libxcursor1 \
    136     libxdamage1 \
    137     libxext6 \
    138     libxfixes3 \
    139     libxi6 \
    140     libxrandr2 \
    141     libxrender1 \
    142     libxtst6 \
    143  && ( apt-get -qy install --no-install-recommends libasound2t64 \
    144       || apt-get -qy install --no-install-recommends libasound2 ) \
    145  && rm -rf /var/lib/apt/lists/*
    146 
    147 # google_apis rather than the bare image: the terminal needs Play-services-free
    148 # Google APIs for its camera and NFC stubs, and x86_64 because every CI worker
    149 # is amd64 and an arm64 image would be translated instruction by instruction.
    150 #
    151 # The system image pulls the emulator in with it, so asking for "emulator" as
    152 # well installs a *second* copy at $ANDROID_HOME/emulator-2 and every
    153 # sdkmanager call afterwards warns about the duplicate ("Observed package id
    154 # 'emulator' in inconsistent location"). It is therefore requested only if the
    155 # image did not already provide it.
    156 RUN yes | sdkmanager "system-images;android-36;google_apis;x86_64" \
    157  && if [ ! -x "${ANDROID_HOME}/emulator/emulator" ]; then \
    158         yes | sdkmanager "emulator"; \
    159     fi \
    160  && test -x "${ANDROID_HOME}/emulator/emulator" \
    161  && test ! -e "${ANDROID_HOME}/emulator-2"
    162 
    163 RUN pipx install git+https://gitlab.com/fdroid/fdroidserver.git \
    164  && fdroid --version
    165 
    166 # The GNU Taler services the *wallet* simulator drives the app against.
    167 #
    168 # The POS simulator talks to the public demo deployment; the wallet simulator
    169 # cannot, because it needs a stack it is allowed to ruin -- it revokes
    170 # denominations, corrupts the wallet's database, injects faults and wipes the
    171 # bank between rounds -- and because the wallet has to reach every service on
    172 # a `localhost` URL, which is what `adb reverse` gives it.  So the whole stack
    173 # runs beside the emulator in this container: exchange, merchant, auditor,
    174 # libeufin bank and donau, on Postgres.  That is about 530 MB in an image
    175 # every job pulls; the same trade as the emulator below, and for the same
    176 # reason -- the buildbot's generic stage step passes only jobCmd, never a
    177 # containerFile, so there is one image.
    178 #
    179 # `sudo` is not a convenience: `backend/stack.sh` creates its database role
    180 # with `sudo -u postgres`, which is how it works on the dedicated host too.
    181 # `iproute2` provides the `ss` that stack.sh waits for ports with -- without
    182 # it the wait silently succeeds and the next service starts into an occupied
    183 # port.  `jq` and `wget` are what taler-unified-setup.sh checks for before it
    184 # does anything at all: without them it exits with "SKIP: jq required" and the
    185 # stack never starts, which stack.sh can only report as "died before becoming
    186 # ready".
    187 RUN apt-get update && apt-get -qy install --no-install-recommends \
    188     donau \
    189     iproute2 \
    190     jq \
    191     libeufin-bank \
    192     postgresql \
    193     sudo \
    194     taler-auditor \
    195     taler-exchange \
    196     taler-exchange-offline \
    197     taler-merchant \
    198     taler-terms-generator \
    199     wget \
    200  && rm -rf /var/lib/apt/lists/* \
    201  && command -v taler-exchange-httpd taler-merchant-httpd taler-auditor-httpd \
    202       libeufin-bank donau-httpd taler-exchange-offline taler-terms-generator \
    203       pg_ctlcluster jq wget > /dev/null
    204 
    205 # `taler-unified-setup.sh` is the one piece of the stack the archive does not
    206 # package.  It is a single script in the exchange's *source* tree (installed
    207 # by `make install`, not by any .deb), and `backend/stack.sh` is written
    208 # around it -- it is what starts the nine services with one call and prints
    209 # `READY:` when they are all answering.
    210 #
    211 # Taken from master rather than from a tag on purpose: the archive's packages
    212 # above are built from master too (they are versioned 1.6.16 while the newest
    213 # tag is v1.6.9), so master's script is the one that matches them.  The clone
    214 # is shallow and discarded in the same layer, so the image carries the 32 kB
    215 # script and not the 45 MB of history.
    216 RUN set -eu; \
    217     git clone --quiet --depth 1 --no-tags \
    218         https://git.taler.net/exchange /tmp/exchange-src; \
    219     install -m 0755 /tmp/exchange-src/src/testing/taler-unified-setup.sh /usr/bin/; \
    220     rm -rf /tmp/exchange-src; \
    221     bash -n /usr/bin/taler-unified-setup.sh; \
    222     grep -q 'READY:' /usr/bin/taler-unified-setup.sh
    223 
    224 # Deployment to F-droid nightly
    225 ENV FDROID_REPO_KEY        /inputs/fdroid-repo-key.txt
    226 ENV NIGHTLY_KEYSTORE_PATH  /inputs/taler-nightly.keystore
    227 ENV NIGHTLY_KEYSTORE_ALIAS androiddebugkey
    228 ENV NIGHTLY_KEYSTORE_PASS  android
    229 ENV FDROID_KEYSTORE_PATH   /inputs/taler-fdroid.keystore
    230 ENV FDROID_KEYSTORE_ALIAS  androidreleasekey
    231 ENV FDROID_KEYSTORE_PASS   android
    232 
    233 # Deployment to taler.net/files
    234 ENV SCP_SSH_KEY  /inputs/wallet.taler.net
    235 ENV SCP_SSH_HOST files@gnunet.org
    236 ENV SCP_SSH_PATH ~
    237 
    238 WORKDIR /workdir