Created
May 17, 2021 07:18
-
-
Save abhaysood/bcfd2713786f1ec8f4749336a20d8c86 to your computer and use it in GitHub Desktop.
Dockerfile to build flutter apps/packages: comes with alpine, FVM, Android SDK, flutter stable, lcov
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM openjdk:8-alpine | |
USER root | |
ARG FVM_VERSION="2.0.4" | |
# Required to build flutter apps on apline | |
ARG GLIBC_VERSION="2.28-r0" | |
ENV LCOV_VERSION="1.15" | |
ENV LCOV_DOWNLOAD_URL="https://github.com/linux-test-project/lcov/releases/download/v${LCOV_VERSION}/lcov-${LCOV_VERSION}.tar.gz" | |
# Install required tools | |
RUN apk -U update && apk -U add \ | |
bash \ | |
ca-certificates \ | |
curl \ | |
git \ | |
make \ | |
libstdc++ \ | |
libgcc \ | |
mesa-dev \ | |
unzip \ | |
wget \ | |
zlib \ | |
perl \ | |
&& wget https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub -O /etc/apk/keys/sgerrand.rsa.pub \ | |
&& wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk -O /tmp/glibc.apk \ | |
&& wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-bin-${GLIBC_VERSION}.apk -O /tmp/glibc-bin.apk \ | |
&& apk add /tmp/glibc.apk /tmp/glibc-bin.apk \ | |
&& rm -rf /tmp/* \ | |
&& rm -rf /var/cache/apk/* \ | |
&& addgroup -g 1000 developer \ | |
&& adduser -u 1000 -G developer -s /bin/bash -D developer | |
# Install lcov | |
RUN curl -L $LCOV_DOWNLOAD_URL > lcov.tar.gz \ | |
&& tar -xf lcov.tar.gz \ | |
&& rm lcov.tar.gz \ | |
&& cd lcov-${LCOV_VERSION} \ | |
&& make install \ | |
&& lcov --version | |
USER developer | |
ARG HOME=/home/developer | |
ENV ANDROID_VERSION="30" | |
ENV ANDROID_BUILD_TOOLS_VERSION="30.0.2" | |
ENV ANDROID_TOOLS_URL="https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip" | |
ENV ANDROID_HOME=${HOME}/android-sdk-linux | |
ENV PATH "${PATH}:${ANDROID_HOME}/cmdline-tools/latest/bin" | |
ENV PATH "${PATH}:${ANDROID_HOME}/cmdline-tools/tools/bin" | |
ENV PATH "${PATH}:${ANDROID_HOME}/tools/bin" | |
ENV PATH "${PATH}:${ANDROID_HOME}/build-tools/${ANDROID_BUILD_TOOLS_VERSION}" | |
ENV PATH "${PATH}:${ANDROID_HOME}/platform-tools" | |
ENV PATH "${PATH}:${ANDROID_HOME}/emulator" | |
ENV PATH "${PATH}:${ANDROID_HOME}/bin" | |
# Download Android SDK | |
RUN mkdir -p $ANDROID_HOME \ | |
&& cd $ANDROID_HOME \ | |
&& curl -o android_tools.zip $ANDROID_TOOLS_URL \ | |
&& unzip -qq -d "$ANDROID_HOME" android_tools.zip \ | |
&& rm android_tools.zip | |
RUN mkdir -p $ANDROID_HOME/cmdline-tools \ | |
&& mv $ANDROID_HOME/tools $ANDROID_HOME/cmdline-tools/tools | |
# Setup Android SDK | |
RUN yes "y" | sdkmanager "build-tools;$ANDROID_BUILD_TOOLS_VERSION" | |
RUN yes "y" | sdkmanager "platforms;android-$ANDROID_VERSION" | |
RUN yes "y" | sdkmanager "platform-tools" | |
RUN yes "y" | sdkmanager "emulator" | |
RUN yes "y" | sdkmanager "system-images;android-$ANDROID_VERSION;google_apis_playstore;x86_64" | |
ENV PATH=$HOME/fvm:$HOME/.pub-cache/bin:$HOME/fvm/default/bin:${PATH} | |
WORKDIR $HOME | |
RUN wget https://github.com/leoafarias/fvm/releases/download/${FVM_VERSION}/fvm-${FVM_VERSION}-linux-x64.tar.gz \ | |
&& tar -xf fvm-${FVM_VERSION}-linux-x64.tar.gz \ | |
&& rm fvm-${FVM_VERSION}-linux-x64.tar.gz \ | |
&& fvm --version | |
# Install flutter stable globally | |
RUN fvm install stable \ | |
&& fvm global stable \ | |
&& flutter config --no-analytics \ | |
&& yes "y" | flutter doctor --android-licenses \ | |
&& flutter doctor \ | |
&& flutter update-packages |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment