Skip to content

Commit

Permalink
Revert "Docker, Dependabot and GitHub Workflows (#1198)"
Browse files Browse the repository at this point in the history
This reverts commit cf0a370.
  • Loading branch information
Catfriend1 authored Dec 10, 2024
1 parent cf0a370 commit db32547
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 279 deletions.
45 changes: 0 additions & 45 deletions .github/dependabot.yml

This file was deleted.

17 changes: 0 additions & 17 deletions .github/pull_request_template.md

This file was deleted.

42 changes: 0 additions & 42 deletions .github/workflows/build-app.yaml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/build-builder.yaml

This file was deleted.

41 changes: 0 additions & 41 deletions .github/workflows/image-builder-template.yaml

This file was deleted.

63 changes: 0 additions & 63 deletions .github/workflows/release-app.yaml

This file was deleted.

46 changes: 15 additions & 31 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,57 +1,41 @@
FROM eclipse-temurin:11-jdk-jammy
FROM openjdk:8

ENV GO_VERSION 1.22.7
ENV GO_VERSION 1.11.4
ENV ANDROID_SDK_VERSION 4333796

# Can be found scrolling down on this page:
# https://developer.android.com/studio/index.html#command-tools
ARG ANDROID_SDK_FILENAME=commandlinetools-linux-9123335_latest.zip
WORKDIR /opt

# The '--reinstall' combined with 'build-essentials' is necessary for cgo
# compilation of go std libs to work. A terrible, arcane hack to solve arkane
# cgo issues - almost fitting.
RUN apt-get update && apt-get install --reinstall --no-install-recommends -y build-essential gcc unzip git gnupg python3

# Install Go
RUN wget -nv https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \
RUN wget -q https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \
tar -zxf go${GO_VERSION}.linux-amd64.tar.gz && \
rm go${GO_VERSION}.linux-amd64.tar.gz
ENV GOROOT /opt/go
ENV PATH /opt/go/bin:${PATH}

# Install Android SDK manager
RUN mkdir -p /opt/android-sdk && cd /opt/android-sdk && \
wget -q https://dl.google.com/android/repository/${ANDROID_SDK_FILENAME} && \
unzip -q ${ANDROID_SDK_FILENAME} && \
rm ${ANDROID_SDK_FILENAME}
wget -q https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_VERSION}.zip && \
unzip -q sdk-tools-linux-${ANDROID_SDK_VERSION}.zip && \
rm sdk-tools-linux-${ANDROID_SDK_VERSION}.zip
ENV ANDROID_HOME /opt/android-sdk

ARG SDKMANAGER="${ANDROID_HOME}/cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME}"

# Accept the SDK license, as we can't install packages otherwise
RUN yes | $SDKMANAGER --licenses > /dev/null

# NDK version
ENV NDK_VERSION 27.0.12077973
ENV TARGET_SDK_VERSION 35
RUN yes | ${ANDROID_HOME}/tools/bin/sdkmanager --licenses

# Install other android packages, including NDK
RUN $SDKMANAGER tools platform-tools "build-tools;${TARGET_SDK_VERSION}.0.0" "platforms;android-${TARGET_SDK_VERSION}" "extras;android;m2repository" "ndk;${NDK_VERSION}"
RUN ${ANDROID_HOME}/tools/bin/sdkmanager tools platform-tools "build-tools;28.0.3" "platforms;android-28" "extras;android;m2repository" ndk-bundle

# Accept licenses of newly installed packages
RUN yes | $SDKMANAGER --licenses
RUN yes | ${ANDROID_HOME}/tools/bin/sdkmanager --licenses

# Setup the NDK path
ENV ANDROID_NDK_HOME ${ANDROID_HOME}/ndk-bundle

# Enable prebuild mode
ENV SYNCTHING_ANDROID_PREBUILT 1

# Set location of go cache
ENV GOCACHE /opt/gocache

# Set location of GOPATH to persist packages for module builds in GOPATH/pkg/mod
ENV GOPATH /opt/gopath

# Run prebuild script (will prebuild stuff into the image if env var is set)
ADD . /opt/syncthing-android
RUN /opt/syncthing-android/docker/prebuild.sh
ADD prebuild.sh /opt/prebuild.sh
RUN /opt/prebuild.sh

WORKDIR /mnt
18 changes: 5 additions & 13 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
# How to use this

## Create the builder image

From inside the checked out syncthing-android repository, run:

`docker build -t syncthing-android-builder:latest -f ./docker/Dockerfile .`

## Build the app

1. From inside the checked out syncthing-android repository, run:
`git submodule init; git submodule update`
2. Actual build:
`docker run --rm -v /tmp/syncthing-android:/mnt syncthing-android-builder ./gradlew buildNative assembleDebug`
3. Retrieve APKs from ./app/build/outputs
1. Build the docker image: `docker build -t syncthing-android-builder:latest .`
2. Checkout syncthing-android somewhere (for the sake of discussion let's say /tmp/syncthing-android)
3. Inside /tmp/syncthing-android, do `git submodule init; git submodule update`
4. Run `docker run --rm -v /tmp/syncthing-android:/mnt syncthing-android-builder ./gradlew buildNative assembleDebug`
5. Retrieve APKs from /tmp/syncthing-android/app/build/outputs
42 changes: 35 additions & 7 deletions docker/prebuild.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,41 @@
#!/bin/bash -e

if [ -z "$SYNCTHING_ANDROID_PREBUILT" ]; then
echo "Prebuild disabled"
rm -rf syncthing-android
exit 0
fi
[ -z "$SYNCTHING_ANDROID_PREBUILT" ] && echo "Prebuild disabled" && exit 0

echo "Prepopulating gradle and go build/pkg cache"
for ARCH in arm x86 arm64; do
GOARCH=${ARCH}
SDK=16
case ${ARCH} in
arm)
GCC="arm-linux-androideabi-clang"
;;
arm64)
SDK=21
GCC="aarch64-linux-android-clang"
;;
x86)
GOARCH=386
GCC="i686-linux-android-clang"
;;
*)
echo "Invalid architecture"
exit 1
esac

STANDALONE_NDK_DIR="${ANDROID_NDK_HOME}/standalone-ndk/android-${SDK}-${GOARCH}"
echo "Building standalone NDK - ${STANDALONE_NDK_DIR}"
${ANDROID_NDK_HOME}/build/tools/make-standalone-toolchain.sh \
--platform=android-${SDK} --arch=${ARCH} \
--install-dir=${STANDALONE_NDK_DIR}

echo "Pre-building Go standard library for $GOARCH"
CGO_ENABLED=1 CC="${STANDALONE_NDK_DIR}/bin/${GCC}" \
GOOS=android GOARCH=$GOARCH go install -v std
done

echo "Prepopulating gradle cache"
git clone https://github.com/syncthing/syncthing-android
cd syncthing-android
./gradlew --no-daemon lint buildNative
./gradlew --no-daemon lint
cd ..
rm -rf syncthing-android

0 comments on commit db32547

Please sign in to comment.