Skip to content

Commit ea3df60

Browse files
committed
Makefile: add docker-tailscale-debug target with persistent debug keystore
The existing docker-run-build target is geared at release builds and requires JKS signing env vars. There was no ergonomic path for the common "iterate on a debug APK inside the build container" workflow. Worse, every docker run produces an APK signed with a fresh ephemeral debug keystore, so `adb install -r` refuses to update a prior install. Add a docker-tailscale-debug target that builds the debug APK inside the container, and bind-mount $(CURDIR)/.android-docker (gitignored) at /root/.android in every docker-* target so the Gradle-generated debug.keystore survives across invocations. Signer stays stable across builds in the same checkout. Note: mount target is /root/.android rather than the Dockerfile's HOME=/build because the JVM's user.home resolves from /etc/passwd (i.e. /root for uid 0), not from the HOME env var. Made while working on #695 Updates #13174 Updates #695
1 parent 728082e commit ea3df60

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ tailscale.jks
2828
# android sdk dir
2929
./android-sdk
3030

31+
# Persistent $HOME/.android for `make docker-*` (keeps debug.keystore so
32+
# the debug signer is stable across container runs).
33+
.android-docker
34+
3135
# Java profiling output
3236
*.hprof
3337

Makefile

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,28 @@ docker-build-image: ## Builds the docker image for the android build environment
365365
docker build -f docker/DockerFile.amd64-build -t $(DOCKER_IMAGE) .; \
366366
fi
367367

368+
# DOCKER_ANDROID_DIR is bind-mounted as /root/.android inside the container
369+
# so the Gradle-generated debug keystore (and anything else under ~/.android)
370+
# persists across docker runs. Without this, every docker-based debug build
371+
# gets a fresh debug.keystore and a different signing cert, so `adb install -r`
372+
# can't update a prior install. Mount target is /root/.android because the
373+
# JVM's user.home resolves to /root for the container's root user, regardless
374+
# of the Dockerfile's HOME=/build env.
375+
DOCKER_ANDROID_DIR := $(CURDIR)/.android-docker
376+
377+
.PHONY: docker-android-dir
378+
docker-android-dir:
379+
@mkdir -p $(DOCKER_ANDROID_DIR)
380+
381+
DOCKER_RUN_VOLS := -v $(CURDIR):/build/tailscale-android -v $(DOCKER_ANDROID_DIR):/root/.android
382+
368383
.PHONY: docker-run-build
369-
docker-run-build: clean jarsign-env docker-build-image ## Runs the docker image for the android build environment and builds release
370-
@docker run --rm -v $(CURDIR):/build/tailscale-android --env JKS_PASSWORD=$(JKS_PASSWORD) --env JKS_PATH=$(JKS_PATH) $(DOCKER_IMAGE)
384+
docker-run-build: clean jarsign-env docker-build-image docker-android-dir ## Runs the docker image for the android build environment and builds release
385+
@docker run --rm $(DOCKER_RUN_VOLS) --env JKS_PASSWORD=$(JKS_PASSWORD) --env JKS_PATH=$(JKS_PATH) $(DOCKER_IMAGE)
386+
387+
.PHONY: docker-tailscale-debug
388+
docker-tailscale-debug: docker-build-image docker-android-dir ## Build tailscale-debug.apk inside the docker env (stable signer across runs)
389+
@docker run --rm $(DOCKER_RUN_VOLS) $(DOCKER_IMAGE) make tailscale-debug
371390

372391
.PHONY: docker-remove-build-image
373392
docker-remove-build-image: ## Removes the current docker build image
@@ -377,8 +396,8 @@ docker-remove-build-image: ## Removes the current docker build image
377396
docker-all: docker-build-image docker-run-build $(DOCKER_IMAGE)
378397

379398
.PHONY: docker-shell
380-
docker-shell: docker-build-image ## Builds a docker image with the android build env and opens a shell
381-
docker run --rm -v $(CURDIR):/build/tailscale-android -it $(DOCKER_IMAGE) /bin/bash
399+
docker-shell: docker-build-image docker-android-dir ## Builds a docker image with the android build env and opens a shell
400+
docker run --rm $(DOCKER_RUN_VOLS) -it $(DOCKER_IMAGE) /bin/bash
382401

383402
.PHONY: docker-remove-shell-image
384403
docker-remove-shell-image: ## Removes all docker shell image

0 commit comments

Comments
 (0)