Skip to content

docker: refactor and update docker image build #636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# with this name, it will be used.
#
# The convention here is tailscale-android-build-amd64-<date>
DOCKER_IMAGE := tailscale-android-build-amd64-031325-1
DOCKER_IMAGE := tailscale-android-build-amd64-041425-1
export TS_USE_TOOLCHAIN=1

# Auto-select an NDK from ANDROID_HOME (choose highest version available)
Expand Down Expand Up @@ -355,13 +355,12 @@ docker-remove-build-image: ## Removes the current docker build image
docker-all: docker-build-image docker-run-build $(DOCKER_IMAGE)

.PHONY: docker-shell
docker-shell: ## Builds a docker image with the android build env and opens a shell
docker build -f docker/DockerFile.amd64-shell -t tailscale-android-shell-amd64 .
docker run --rm -v $(CURDIR):/build/tailscale-android -it tailscale-android-shell-amd64
docker-shell: docker-build-image ## Builds a docker image with the android build env and opens a shell
docker run --rm -v $(CURDIR):/build/tailscale-android -it $(DOCKER_IMAGE) /bin/bash

.PHONY: docker-remove-shell-image
docker-remove-shell-image: ## Removes all docker shell image
docker rmi --force tailscale-android-shell-amd64
@echo "docker-remove-shell-image retained for backward compatibility, but is a no-op; docker-shell now uses build image"

.PHONY: clean
clean: ## Remove build artifacts. Does not purge docker build envs. Use dockerRemoveEnv for that.
Expand Down
38 changes: 19 additions & 19 deletions docker/DockerFile.amd64-build
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,30 @@

FROM --platform=linux/amd64 eclipse-temurin:21

# To enable running android tools such as aapt
RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y libz1 libstdc++6 unzip zip
# For Go:
RUN apt-get -y --no-install-recommends install curl gcc
RUN apt-get -y --no-install-recommends install ca-certificates libc6-dev git

RUN apt-get -y install make

RUN mkdir -p build
ENV HOME /build

# Make android sdk location, the later make step will populate it.
RUN mkdir android-sdk
ENV ANDROID_HOME $HOME/android-sdk
ENV ANDROID_SDK_ROOT $ANDROID_HOME
ENV PATH $PATH:$HOME/bin:$ANDROID_HOME/platform-tools

RUN mkdir -p \
${HOME} \
/android-sdk \
${ANDROID_HOME} \
$HOME/tailscale-android

# To enable running android tools such as aapt
COPY scripts/docker-build-apt-get.sh /tmp
RUN chmod 755 /tmp/docker-build-apt-get.sh && \
/tmp/docker-build-apt-get.sh && \
rm -f /tmp/docker-build-apt-get.sh

# We need some version of Go new enough to support the "embed" package
# to run "go run tailscale.com/cmd/printdep" to figure out which Tailscale Go
# version we need later, but otherwise this toolchain isn't used:
RUN curl -L https://go.dev/dl/go1.23.0.linux-amd64.tar.gz | tar -C /usr/local -zxv
RUN ln -s /usr/local/go/bin/go /usr/bin
RUN \
curl -L https://go.dev/dl/go1.24.1.linux-amd64.tar.gz | tar -C /usr/local -zxv && \
ln -s /usr/local/go/bin/go /usr/bin

RUN mkdir -p $HOME/tailscale-android
RUN git config --global --add safe.directory $HOME/tailscale-android
WORKDIR $HOME/tailscale-android

Expand All @@ -37,10 +36,11 @@ COPY Makefile Makefile
RUN make androidsdk

# Preload Gradle
COPY android/gradlew android/gradlew
COPY android/gradlew android/build.gradle android
COPY android/gradle android/gradle
RUN ./android/gradlew

RUN chmod 755 android/gradlew && \
./android/gradlew

# Build the android app, bump the playstore version code, and make the tv release
CMD make clean && make release && make bump_version_code && make release-tv

47 changes: 0 additions & 47 deletions docker/DockerFile.amd64-shell

This file was deleted.

39 changes: 39 additions & 0 deletions scripts/docker-build-apt-get.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh
#
# Copyright (c) Tailscale Inc & AUTHORS
# SPDX-License-Identifier: BSD-3-Clause
#
# docker-build-apt-get.sh runs 'apt'-related commands inside
# the environment that /builds the docker image/
set -x
set -e

apt-get update
apt-get -y upgrade

apt-get -y install \
\
libstdc++6 \
libz1 \
make \
unzip \
zip \
\
# end of sort region

apt-get -y --no-install-recommends install \
\
ca-certificates \
curl \
gcc \
git \
libc6-dev \
\
# end of sort region

apt-get -y clean

rm -rf \
/var/cache/debconf \
/var/lib/apt/lists \
/var/lib/apt/dpkg