diff --git a/docker/Dockerfile b/docker/Dockerfile index 83579067..4f8ea8a9 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -47,7 +47,7 @@ ENV GOCACHE /opt/gocache ENV GOPATH /opt/gopath # Run prebuild script (will prebuild stuff into the image if env var is set) -ADD prebuild.sh /opt/prebuild.sh -RUN /opt/prebuild.sh +ADD . /opt/syncthing-android +RUN /opt/syncthing-android/docker/prebuild.sh WORKDIR /mnt diff --git a/docker/README.md b/docker/README.md index 99546eb6..39038d0f 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,7 +1,15 @@ # How to use this -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 +## 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 diff --git a/docker/prebuild.sh b/docker/prebuild.sh index a6a20692..117e64dc 100755 --- a/docker/prebuild.sh +++ b/docker/prebuild.sh @@ -1,9 +1,12 @@ #!/bin/bash -e -[ -z "$SYNCTHING_ANDROID_PREBUILT" ] && echo "Prebuild disabled" && exit 0 +if [ -z "$SYNCTHING_ANDROID_PREBUILT" ]; then + echo "Prebuild disabled" + rm -rf syncthing-android + exit 0 +fi echo "Prepopulating gradle and go build/pkg cache" -git clone --recurse-submodules https://github.com/syncthing/syncthing-android cd syncthing-android ./gradlew --no-daemon lint buildNative cd ..