Skip to content

Instantly share code, notes, and snippets.

@aleksul
Last active October 29, 2021 14:01
Show Gist options
  • Save aleksul/bda07eab6204375b6e4e18d559df4484 to your computer and use it in GitHub Desktop.
Save aleksul/bda07eab6204375b6e4e18d559df4484 to your computer and use it in GitHub Desktop.
Godot v3.3.4 Android export Dockerfile
FROM ubuntu:focal
ENV GODOT_VERSION "3.3.4"
ENV COMMANDLINETOOLS_VERSION "7583922_latest"
ENV ANDROID_API "29"
ENV BUILD_TOOLS "30.0.3"
ENV CMAKE_VERSION "3.10.2.4988404"
ENV NDK_VERSION "21.4.7075529"
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get -q update \
&& apt-get -q install -y --no-install-recommends \
tzdata \
ca-certificates \
git \
python \
python-openssl \
unzip \
wget \
zip \
curl \
openjdk-11-jdk \
&& apt-get clean
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64
WORKDIR /build
# Download and install Godot
RUN wget -q --waitretry=1 --retry-connrefused -T 10 https://downloads.tuxfamily.org/godotengine/${GODOT_VERSION}/Godot_v${GODOT_VERSION}-stable_linux_headless.64.zip -O /build/godot.zip \
&& unzip -q -d /build /build/godot.zip \
&& mv /build/Godot* /usr/local/bin/godot \
&& mkdir ~/.cache \
&& mkdir -p ~/.config/godot
# Download and install Godot export templates
RUN wget -q --waitretry=1 --retry-connrefused -T 10 https://downloads.tuxfamily.org/godotengine/${GODOT_VERSION}/Godot_v${GODOT_VERSION}-stable_export_templates.tpz -O /build/Godot_v${GODOT_VERSION}-stable_export_templates.tpz \
&& unzip -q -d /build /build/Godot_v${GODOT_VERSION}-stable_export_templates.tpz \
&& mkdir -p ~/.local/share/godot/templates/${GODOT_VERSION}.stable \
&& mv /build/templates/* ~/.local/share/godot/templates/${GODOT_VERSION}.stable
RUN rm -rf /build
WORKDIR /root/android
# Download and install command line tools
RUN curl -fsSLO https://dl.google.com/android/repository/commandlinetools-linux-${COMMANDLINETOOLS_VERSION}.zip \
&& unzip -q commandlinetools-linux-*.zip \
&& mv cmdline-tools latest \
&& rm -f commandlinetools-linux-*.zip
# Download and install SDK tools, accept licences, and create debug.keystore
ENV ANDROID_HOME /root/android
RUN mkdir -p /root/.android && echo "count=0" > /root/.android/repositories.cfg
RUN yes | latest/bin/sdkmanager --sdk_root=$ANDROID_HOME --licenses
RUN yes | latest/bin/sdkmanager --sdk_root=$ANDROID_HOME "platform-tools"
RUN yes | latest/bin/sdkmanager --sdk_root=$ANDROID_HOME "build-tools;${BUILD_TOOLS}"
RUN yes | latest/bin/sdkmanager --sdk_root=$ANDROID_HOME "platforms;android-${ANDROID_API}"
RUN yes | latest/bin/sdkmanager --sdk_root=$ANDROID_HOME "cmdline-tools;latest"
RUN yes | latest/bin/sdkmanager --sdk_root=$ANDROID_HOME "cmake;${CMAKE_VERSION}"
RUN yes | latest/bin/sdkmanager --sdk_root=$ANDROID_HOME "ndk;${NDK_VERSION}"
RUN keytool -keyalg RSA -genkeypair -alias androiddebugkey -keypass android -keystore debug.keystore -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999
# Initialize Godot so it creates editor_settings-3.tres file, then add android export section
WORKDIR /
RUN godot -e -q
RUN echo 'export/android/debug_keystore = "/root/android/debug.keystore"' >> ~/.config/godot/editor_settings-3.tres \
&& echo 'export/android/debug_keystore_user = "androiddebugkey"' >> ~/.config/godot/editor_settings-3.tres \
&& echo 'export/android/debug_keystore_pass = "android"' >> ~/.config/godot/editor_settings-3.tres \
&& echo 'export/android/android_sdk_path = "/root/android"' >> ~/.config/godot/editor_settings-3.tres
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment