-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathContainerfile
79 lines (70 loc) · 3.15 KB
/
Containerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
FROM rust:bookworm
#
ARG VERSION="stable"
ARG FLUTTER_URL="https://github.com/flutter/flutter"
ARG ANDROID_SDK_TOOLS_VERSION=9477386
ARG ANDROID_NDK_VERSION=r25c
ARG FLUTTER_HOME="/opt/flutter"
ARG ANDROID_HOME="/opt/android"
ARG ANDROID_NDK="$ANDROID_HOME/ndk-bundle"
USER root
WORKDIR /
ENV VERSION=$VERSION \
EDITOR="code" \
PUB_CACHE="/var/tmp/.pub_cache" \
FLUTTER_HOME=$FLUTTER_HOME \
FLUTTER_ROOT=$FLUTTER_HOME \
ANDROID_HOME=$ANDROID_HOME \
ANDROID_NDK=$ANDROID_NDK \
ANDROID_NDK_HOME=$ANDROID_NDK \
DART_HOME="/opt/dart" \
PATH="${PATH}:${FLUTTER_HOME}/bin:${PUB_CACHE}/bin:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools:${DART_HOME}}/bin"
# Install linux dependency and utils
RUN set -eux; mkdir -p /usr/lib $PUB_CACHE \
&& apt-get update \
&& apt-get install -y openjdk-17-jdk \
&& rm -rf /var/lib/apt/lists/* /var/cache/apk/* \
&& mkdir -p ${ANDROID_HOME}/cmdline-tools /root/.android
# Install & config Flutter
RUN set -eux; git clone -b ${VERSION} --depth 1 "${FLUTTER_URL}.git" "${FLUTTER_ROOT}" \
&& cd "${FLUTTER_ROOT}" \
&& git gc --prune=all
# Install the Android SDK Dependency.
RUN set -eux; wget -q https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS_VERSION}_latest.zip -O /tmp/android-sdk-tools.zip \
&& unzip -q /tmp/android-sdk-tools.zip -d /tmp/ \
&& mv /tmp/cmdline-tools ${ANDROID_HOME}/cmdline-tools/latest/ \
&& rm -rf /tmp/* \
&& touch /root/.android/repositories.cfg \
&& yes | sdkmanager --sdk_root=${ANDROID_HOME} --licenses \
&& sdkmanager --sdk_root=${ANDROID_HOME} --install "platform-tools"
# Install dart sdk
RUN set -eux; wget -q https://storage.googleapis.com/dart-archive/channels/be/raw/latest/sdk/dartsdk-linux-x64-release.zip -O /tmp/dart-sdk.zip \
&& unzip -q /tmp/dart-sdk.zip -d /tmp/ \
&& mv /tmp/dart-sdk $DART_HOME \
&& rm -rf /tmp/* \
&& dart --disable-analytics && flutter config --no-analytics \
&& flutter doctor && flutter precache --universal --android
# Init android dependency and utils
RUN set -eux; cd "${FLUTTER_HOME}/bin" \
&& yes "y" | flutter doctor --android-licenses \
&& sdkmanager --sdk_root=${ANDROID_HOME} --install "platform-tools" "emulator" "extras;google;instantapps" \
&& sdkmanager --sdk_root=${ANDROID_HOME} --install "platforms;android-31" "platforms;android-32" "build-tools;29.0.2" \
&& wget -q https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux.zip -O /tmp/android-ndk.zip \
&& unzip -q /tmp/android-ndk.zip -d /tmp/ndk/ \
&& mv /tmp/ndk/*/ $ANDROID_NDK \
&& rm -rf /tmp/*
# Install rust tools
RUN set -eux; apt-get update && apt-get install -y libclang-dev \
&& cargo install just \
cargo-ndk \
flutter_rust_bridge_codegen \
# we dont really need this because we dont use macros in our rust code but for
# now there is no option to disable cargo expand in flutter_rust_bridge_codegen
cargo-expand \
&& rustup component add rustfmt \
&& rustup target add \
aarch64-linux-android \
armv7-linux-androideabi \
x86_64-linux-android \
i686-linux-android
WORKDIR /home/root