docker run \
--rm \
-v ~/.gradle:/root/.gradle \
-v $PWD:/app \
-w /app \
android bash gradlew clean :app:assembleRelease
docker compose up -d
# 基础镜像根据项目需要,选择带有指定 Java 版本的 Ubuntu 系统
FROM eclipse-temurin:11
# 设置环境变量
ENV ANDROID_HOME=/opt/android/sdk
# RUN/COPY 尽量写在一条语句中,Docker 采用分层设计,每执行一句 RUN/COPY 会形成一个新的 layer,增加最终的镜像大小
# 每个 layer 会产生一个 cache,在需要缓存的时候,可分多句编写,如 RUN pip install -r requirements.txt 等
RUN set -eux; \
apt-get update; \
apt-get install -y unzip; \
wget -O commandlinetools-linux.zip https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip; \
unzip commandlinetools-linux.zip;\
rm commandlinetools-linux.zip; \
mkdir -p $ANDROID_HOME/cmdline-tools; \
mv cmdline-tools $ANDROID_HOME/cmdline-tools/latest; \
yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses; \
$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "platforms;android-33"; \
rm -rf /var/lib/apt/lists/*
FROM android
ARG FLUTTER_VERSION
WORKDIR /opt
ENV PATH=$PATH:/opt/flutter/bin \
PUB_HOSTED_URL=https://pub.flutter-io.cn \
FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
RUN set -eux; \
apt-get update; \
apt-get install -y file git xz-utils zip; \
wget https://storage.flutter-io.cn/flutter_infra_release/releases/stable/linux/flutter_linux_$FLUTTER_VERSION-stable.tar.xz; \
tar xf flutter_linux_$FLUTTER_VERSION-stable.tar.xz; \
rm flutter_linux_$FLUTTER_VERSION-stable.tar.xz; \
chown -R root:root flutter; \
flutter config --no-analytics; \
rm -rf /var/lib/apt/lists/*
lsof -i -P | grep LISTEN
docker build -t android .
docker build -t flutter --build-arg FLUTTER_VERSION=3.7.6 .
docker run \
--rm \
-v ~/.gradle:/root/.gradle \
-v $PWD:/app \
-w /app \
android bash gradlew clean :app:assembleRelease
docker run \
--rm \
-v $PWD:/app \
-w /app \
flutter flutter build apk