docker: refactor and update docker image build
Fixes tailscale/tailscale#15674 update docker image datestamp make docker-shell target use the build image with an explicit /bin/bash command retain the docker-remove-shell-image target in case something depends on it, but clarify that it is now a no-op hoist all ENV declarations hoist all mkdir commands combine mkdir commands use env vars in mkdir combine apt-get commands into single RUN make argument order consistent in apt-get commands collect packages into fewer apt-get commands add clean up of temporary files after apt-get expand apt-get commands to one package per line sort packages in apt-get commands combine go installation commands into single RUN update golang version to 1.24.1 also copy build.gradle file ensure gradlew is executable before running remove trailing newline per review comment, extract multiline apt-get command into shell script, copy and run that shell script within image during docker build Signed-off-by: Sam Mikes (He/him/his) <sam.mikes@gm.com>pull/638/head
parent
a684f89eea
commit
22dabbeeb5
@ -1,47 +0,0 @@
|
||||
# This is a Dockerfile for creating a build environment for
|
||||
# tailscale-android.
|
||||
|
||||
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
|
||||
|
||||
# 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 mkdir -p $HOME/tailscale-android
|
||||
RUN git config --global --add safe.directory $HOME/tailscale-android
|
||||
WORKDIR $HOME/tailscale-android
|
||||
|
||||
COPY Makefile Makefile
|
||||
|
||||
# Get android sdk, ndk, and rest of the stuff needed to build the android app.
|
||||
RUN make androidsdk
|
||||
|
||||
# Preload Gradle
|
||||
COPY android/gradlew android/gradlew
|
||||
COPY android/gradle android/gradle
|
||||
RUN ./android/gradlew
|
||||
|
||||
# Run a shell
|
||||
CMD /bin/bash
|
||||
|
||||
|
||||
@ -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
|
||||
Loading…
Reference in New Issue