FROM cirrusci/flutter:latest # Set working directory for the app WORKDIR /project # Copy the repository source into the container COPY . . # Preflight: show doctor info and installed tools RUN flutter doctor -v # Accept Android licenses if Android tools are present RUN yes | flutter doctor --android-licenses || true # Install project dependencies if this is a Flutter project RUN if [ -f pubspec.yaml ]; then flutter pub get; fi # Build the Android APK from source if possible RUN if [ -f pubspec.yaml ]; then flutter build apk --release; fi # Provide an interactive shell by default CMD ["/bin/bash"]
# Flutter/Direbase project ignore rules .git **/build build/ .dart_tool/ .flutter-plugins .flutter-plugins-dependencies .packages .pub-cache .pub ios/Pods ios/Flutter/Flutter.framework android/.gradle android/app/build .DS_Store
Summary of Docker build error - Failing step (command/step): [6/7] RUN if [ -f pubspec.yaml ]; then flutter pub get; fi - Exact error messages and exit code: Because karing requires SDK version >=3.9.0 <4.0.0, version solving failed. pub get failed exit code: 1 - Missing packages or files mentioned: No missing files reported. The failure is a dependency version constraint issue (karing requires Dart SDK 3.x, but the current SDK is 2.x). - Version mismatch information: The current Dart SDK version is 2.19.4. Because karing requires SDK version >=3.9.0 <4.0.0, version solving failed.
# Stage 1: Build the Android app from source using Android SDK and Gradle
FROM openjdk:17-jdk-slim as builder
ENV ANDROID_SDK_ROOT=/sdk
ENV PATH=${PATH}:${ANDROID_SDK_ROOT}/platform-tools:${ANDROID_SDK_ROOT}/emulator:${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin:${ANDROID_SDK_ROOT}/tools/bin
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl unzip git ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install Android command-line tools
RUN mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools && \
cd /tmp && \
curl -Lo commandlinetools-linux.zip https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip && \
unzip commandlinetools-linux.zip -d ${ANDROID_SDK_ROOT}/cmdline-tools && \
rm commandlinetools-linux.zip && \
mv ${ANDROID_SDK_ROOT}/cmdline-tools/cmdline-tools ${ANDROID_SDK_ROOT}/cmdline-tools/latest
RUN yes | ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=${ANDROID_SDK_ROOT} \
"platform-tools" \
"platforms;android-35" \
"build-tools;35.0.3"
WORKDIR /project
COPY . .
# Build the Android app (release)
RUN cd android && ./gradlew clean assembleRelease
# If the APK exists, copy it to a stable path for the runtime image
RUN if [ -f android/app/build/outputs/apk/release/app-release.apk ]; then cp android/app/build/outputs/apk/release/app-release.apk /project/app-release.apk; fi
# Stage 2: Lightweight runtime image containing the built APK
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the built APK from the builder stage
COPY --from=builder /project/app-release.apk ./karing-app-release.apk
# Provide an interactive shell as the default command
CMD ["bash"]
FROM debian:bullseye-slim as builder
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl unzip git ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install OpenJDK 17
RUN apt-get update \
&& apt-get install -y --no-install-recommends openjdk-17-jdk \
&& rm -rf /var/lib/apt/lists/*
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
ENV PATH=$PATH:$JAVA_HOME/bin
# Android SDK setup
ENV ANDROID_SDK_ROOT=/sdk
ENV PATH=${PATH}:${ANDROID_SDK_ROOT}/platform-tools:${ANDROID_SDK_ROOT}/emulator:${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin
RUN mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools && \
cd /tmp && \
curl -Lo commandlinetools-linux.zip https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip && \
unzip commandlinetools-linux.zip -d ${ANDROID_SDK_ROOT}/cmdline-tools && \
rm commandlinetools-linux.zip && \
mv ${ANDROID_SDK_ROOT}/cmdline-tools/cmdline-tools ${ANDROID_SDK_ROOT}/cmdline-tools/latest
RUN mkdir -p ${ANDROID_SDK_ROOT}/licenses
RUN yes | ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=${ANDROID_SDK_ROOT} \
"platform-tools" \
"platforms;android-35" \
"build-tools;35.0.3"
WORKDIR /project
COPY . .
# Try to build Android app (if Gradle wrapper is present)
RUN cd android && if [ -x ./gradlew ]; then ./gradlew clean assembleRelease; fi
# If APK exists, copy to known path
RUN if [ -f android/app/build/outputs/apk/release/app-release.apk ]; then cp android/app/build/outputs/apk/release/app-release.apk /project/app-release.apk; fi
FROM debian:bookworm-slim as runtime
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /project/app-release.apk ./karing-app-release.apk
CMD ["bash"]
- Exact error message and exit code
ERROR: failed to build: failed to solve: process "/bin/sh -c yes | ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=${ANDROID_SDK_ROOT} \"platform-tools\" \"platforms;android-35\" \"build-tools;35.0.3\"" did not complete successfully: exit code: 1
- Failing command/step
[builder 6/10] RUN yes | /sdk/cmdline-tools/latest/bin/sdkmanager --sdk_root=/sdk "platform-tools" "platforms;android-35" "build-tools;35.0.3"
- Missing packages or files mentioned
- Warning: Failed to find package 'build-tools;35.0.3'
- This indicates the requested Android build-tools 35.0.3 package is not available in the configured sdkmanager repositories.
- Version mismatch information
- Multi-stage build shows a base image mismatch between stages:
- Builder uses debian:bullseye-slim (bullseye)
- Runtime uses debian:bookworm-slim (bookworm)
This suggests a Debian version mismatch across stages that may contribute to the error.FROM eclipse-temurin:17-jdk-jammy AS builder
LABEL stage="builder" \
description="Build Karing Android (Flutter-augmented) APK from source using JDK 17, Android SDK, and Flutter SDK"
ENV DEBIAN_FRONTEND=noninteractive
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
unzip \
git \
ca-certificates \
build-essential \
zip \
gradle \
&& rm -rf /var/lib/apt/lists/*
# Android SDK setup
ENV ANDROID_SDK_ROOT=/opt/android-sdk
ENV ANDROID_HOME=${ANDROID_SDK_ROOT}
ENV PATH="${PATH}:${ANDROID_SDK_ROOT}/platform-tools:${ANDROID_SDK_ROOT}/emulator:${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin"
RUN mkdir -p "$ANDROID_SDK_ROOT" && \
mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools" && \
curl -fsSL https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip -o /tmp/commandlinetools.zip && \
unzip -q /tmp/commandlinetools.zip -d "$ANDROID_SDK_ROOT/cmdline-tools" && \
rm /tmp/commandlinetools.zip && \
mv "$ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools" "$ANDROID_SDK_ROOT/cmdline-tools/latest" \
# Accept licenses and install required Android packages
RUN yes | sdkmanager --licenses
RUN yes | sdkmanager "platform-tools" "platforms;android-35" "build-tools;36.0.0" "ndk;28.2.13676358"
# Flutter SDK (stable)
ENV FLUTTER_ROOT=/opt/flutter
RUN git clone https://github.com/flutter/flutter.git --branch stable /opt/flutter
ENV PATH="$PATH:/opt/flutter/bin"
RUN flutter --version
RUN flutter precache
# Copy source and build
WORKDIR /project
COPY . .
# Build the Android app (debug) to produce an APK
WORKDIR /project/android
RUN gradle -v
RUN gradle :app:assembleDebug || true
# Copy APK to a known path if produced
RUN sh -c 'if ls android/app/build/outputs/apk/debug/*.apk 1> /dev/null 2>&1; then \
mkdir -p /project/outputs; \
cp android/app/build/outputs/apk/debug/*.apk /project/outputs/karing-app-debug.apk; \
else \
echo "APK not found in expected path"; \
fi'
# Final runtime image (container exposes the built APK for retrieval)
FROM debian:bookworm-slim AS final
LABEL stage="final" \
description="Container with built APK accessible at /outputs/karing-app-debug.apk"
COPY --from=builder /project/outputs/karing-app-debug.apk /outputs/karing-app-debug.apk
CMD ["bash","-lc","if [ -f /outputs/karing-app-debug.apk ]; then echo 'Build complete. APK located at /outputs/karing-app-debug.apk'; else echo 'APK not found'; fi; tail -f /dev/null"]
Build status: build_failed Concerns - Final runtime image uses Debian bookworm-slim and CMD invokes bash; if bash not installed, container may fail to start. Consider /bin/sh or install bash. - Build step uses 'gradle :app:assembleDebug || true'; swallows build failures. If APK isn’t produced, final COPY will fail. Consider ./gradlew and remove '|| true' to fail fast. Build error (Android SDK step) - Exact errors and exit code: - /bin/sh: 1: sdkmanager: not found - mv: target 'yes' is not a directory - ERROR: failed to build: failed to solve: process "/bin/sh -c mkdir -p \"$ANDROID_SDK_ROOT\" && mkdir -p \"$ANDROID_SDK_ROOT/cmdline-tools\" && curl -fsSL https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip -o /tmp/commandlinetools.zip && unzip -q /tmp/commandlinetools.zip -d \"$ANDROID_SDK_ROOT/cmdline-tools\" && rm /tmp/commandlinetools.zip && mv \"$ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools\" \"$ANDROID_SDK_ROOT/cmdline-tools/latest\" RUN yes | sdkmanager --licenses" did not complete successfully: exit code: 127 Failing command/step - Step: [builder 3/13] RUN mkdir -p "/opt/android-sdk" && mkdir -p "/opt/android-sdk/cmdline-tools" && curl -fsSL https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip -o /tmp/commandlinetools.zip && unzip -q /tmp/commandlinetools.zip -d "/opt/android-sdk/cmdline-tools" && rm /tmp/commandlinetools.zip && mv "/opt/android-sdk/cmdline-tools/cmdline-tools" "/opt/android-sdk/cmdline-tools/latest" RUN yes | sdkmanager --licenses Missing packages/files - sdkmanager: not found (binary not available on PATH after extraction) - The command downloads commandlinetools-linux-9477386_latest.zip and extracts it, but sdkmanager isn’t found at runtime Version/mismatch info - Downloaded tool version: commandlinetools-linux-9477386_latest.zip - Extraction path: /opt/android-sdk/cmdline-tools - Expected location for sdkmanager after extraction: path indicates /opt/android-sdk/cmdline-tools/latest, but sdkmanager isn’t found on PATH Notes - Dockerfile syntax issue: the previous RUN ends with mv "...latest" and a subsequent RUN appears concatenated, causing the shell to misinterpret and try to run "RUN yes | sdkmanager --licenses" as part of the same command. This contributes to sdkmanager not found and mv errors. Actionable items - Separate RUN commands correctly; ensure the sdkmanager step is a distinct RUN (and that the path to sdkmanager is correct). - Verify sdkmanager installation and PATH; confirm exact location after extracting commandlinetools (often cmdline-tools/bin/sdkmanager or similar per version). - Consider using the Gradle wrapper (./gradlew) and remove || true to avoid swallowing build errors. - If using bash in final image, ensure bash is installed or switch to /bin/sh.
FROM eclipse-temurin:17-jdk-jammy AS builder
LABEL maintainer="BuildAgent" \
description="Karing Android app build with Gradle and Flutter in a multi-stage Docker image"
ENV DEBIAN_FRONTEND=noninteractive
# Install required system utilities
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
unzip \
git \
ca-certificates \
build-essential \
python3 \
python3-pip \
software-properties-common \
libnss3 \
&& rm -rf /var/lib/apt/lists/*
# Android SDK installation (command-line tools)
ENV ANDROID_SDK_ROOT=/opt/android-sdk
ENV ANDROID_HOME=${ANDROID_SDK_ROOT}
ENV PATH="${PATH}:${ANDROID_SDK_ROOT}/platform-tools:${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin"
RUN mkdir -p "$ANDROID_SDK_ROOT" && \
mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools" && \
curl -fsSL https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip -o /tmp/commandlinetools.zip && \
unzip -q /tmp/commandlinetools.zip -d "$ANDROID_SDK_ROOT/cmdline-tools" && \
rm /tmp/commandlinetools.zip && \
mv "$ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools" "$ANDROID_SDK_ROOT/cmdline-tools/latest" && \
chmod -R a+rX "$ANDROID_SDK_ROOT" \
# Accept licenses and install required Android packages
RUN yes | "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --licenses
RUN "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" \
"platform-tools" \
"platforms;android-35" \
"build-tools;36.0.0" \
"ndk;28.2.13676358"
# Flutter SDK setup
RUN git clone https://github.com/flutter/flutter.git /opt/flutter --depth 1
ENV FLUTTER_ROOT=/opt/flutter
ENV PATH="${PATH}:/opt/flutter/bin:$FLUTTER_ROOT/bin/cache/dart-sdk/bin"
RUN flutter --version || true
RUN flutter precache || true
# Copy source and build
WORKDIR /project
COPY . .
# Build the Android app (debug) to produce an APK
WORKDIR /project/android
RUN ./gradlew clean assembleDebug || true
# Copy produced APKs to a shared outputs directory
RUN mkdir -p /project/outputs && \
bash -lc 'if ls app/build/outputs/apk/debug/*.apk 1> /dev/null 2>&1; then cp app/build/outputs/apk/debug/*.apk /project/outputs/karing-app-debug.apk; fi' || true
RUN bash -lc 'if ls app/build/outputs/apk/release/*.apk 1> /dev/null 2>&1; then cp app/build/outputs/apk/release/*.apk /project/outputs/karing-app-release.apk; fi' || true
# Final runtime image that just exposes the built APK
FROM debian:bookworm-slim AS final
LABEL maintainer="BuildAgent" \
description="Container with built APK available at /outputs"
COPY --from=builder /project/outputs /outputs
CMD ["bash","-lc","if [ -f /outputs/karing-app-debug.apk ]; then echo 'Debug APK: /outputs/karing-app-debug.apk'; fi; if [ -f /outputs/karing-app-release.apk ]; then echo 'Release APK: /outputs/karing-app-release.apk'; fi; tail -f /dev/null"]
Concerns: Syntax error: a RUN instruction ends with a trailing backslash and is followed by another separate RUN instruction, which Dockerfile syntax does not support. This will likely fail to build., The use of '|| true' on build steps may hide actual build failures (e.g., the APK may not be produced while the build continues)., The multi-stage build relies on network-heavy operations (Android SDK, Flutter) which can be brittle in constrained CI environments; consider pinning versions and validating the build more strictly.
FROM eclipse-temurin:17-jdk-jammy AS builder
LABEL maintainer="BuildAgent" \
description="Karing Android app build with Gradle and Flutter in a multi-stage Docker image"
ENV DEBIAN_FRONTEND=noninteractive
# Install required system utilities
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
unzip \
git \
ca-certificates \
build-essential \
python3 \
python3-pip \
software-properties-common \
libnss3 \
&& rm -rf /var/lib/apt/lists/*
# Android SDK installation (command-line tools)
ENV ANDROID_SDK_ROOT=/opt/android-sdk
ENV ANDROID_HOME=${ANDROID_SDK_ROOT}
ENV PATH="${PATH}:${ANDROID_SDK_ROOT}/platform-tools:${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin"
RUN mkdir -p "$ANDROID_SDK_ROOT" && \
mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools" && \
curl -fsSL https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip -o /tmp/commandlinetools.zip && \
unzip -q /tmp/commandlinetools.zip -d "$ANDROID_SDK_ROOT/cmdline-tools" && \
rm /tmp/commandlinetools.zip && \
mv "$ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools" "$ANDROID_SDK_ROOT/cmdline-tools/latest" && \
chmod -R a+rX "$ANDROID_SDK_ROOT" \
# Accept licenses and install required Android packages
RUN "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --licenses || true
RUN "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" \
"platform-tools" \
"platforms;android-35" \
"build-tools;36.0.0" \
"ndk;28.2.13676358"
# Flutter SDK setup
RUN git clone https://github.com/flutter/flutter.git /opt/flutter --depth 1
ENV FLUTTER_ROOT=/opt/flutter
ENV PATH="${PATH}:/opt/flutter/bin:$FLUTTER_ROOT/bin/cache/dart-sdk/bin"
RUN flutter --version || true
RUN flutter precache || true
# Copy source and build
WORKDIR /project
COPY . .
# Build the Android app (debug) to produce an APK
WORKDIR /project/android
RUN ./gradlew clean assembleDebug
# Copy produced APKs to a shared outputs directory
RUN mkdir -p /project/outputs && \
bash -lc 'if ls app/build/outputs/apk/debug/*.apk 1> /dev/null 2>&1; then cp app/build/outputs/apk/debug/*.apk /project/outputs/karing-app-debug.apk; fi'
RUN bash -lc 'if ls app/build/outputs/apk/release/*.apk 1> /dev/null 2>&1; then cp app/build/outputs/apk/release/*.apk /project/outputs/karing-app-release.apk; fi'
# Final runtime image that just exposes the built APK
FROM debian:bookworm-slim AS final
LABEL maintainer="BuildAgent" \
description="Container with built APK available at /outputs"
RUN apt-get update && apt-get install -y --no-install-recommends bash ca-certificates && rm -rf /var/lib/apt/lists/*
COPY --from=builder /project/outputs /outputs
CMD ["/bin/bash","-lc","if [ -f /outputs/karing-app-debug.apk ]; then echo 'Debug APK: /outputs/karing-app-debug.apk'; fi; if [ -f /outputs/karing-app-release.apk ]; then echo 'Release APK: /outputs/karing-app-release.apk'; fi; tail -f /dev/null"]
- Exact error message and exit code
- /bin/sh: 1: ./gradlew: not found
- Exit code: 127
- Failing command/step
- Failing step: builder 11/13
- Command: RUN ./gradlew clean assembleDebug
- Context: invoked from /project/android; Docker reports the process "/bin/sh -c ./gradlew clean assembleDebug" did not complete successfully: exit code: 127
- Missing packages or files mentioned
- gradlew file not found: "./gradlew: not found"
- Android SDK license acceptance path indicates certain packages could not be installed due to licenses not being accepted:
- ndk;28.2.13676358
- build-tools;36.0.0
- platforms;android-35
- platform-tools
- Version mismatch / configuration notes
- Multi-stage base images show OS/version mismatch:
- Stage uses Debian: bookworm-slim
- Another stage uses Eclipse Temurin with jammy (Ubuntu 22.04)
- This mixing could cause apt-version/package-source inconsistencies
- Flutter environment details observed:
- Flutter 3.43.0-0.3.pre • channel master
- Engine hash bf20aca662653d5433c27147c22953cd3f67f1e8 (6 hours ago)
- Dart 3.13.0 (build 3.13.0-10.0.dev)
- Notable earlier behavior: a step attempted to run sdkmanager licenses flow and encountered a license prompt (Android SDK license acceptance).