docker-images-flutter icon indicating copy to clipboard operation
docker-images-flutter copied to clipboard

[Help] Compatiblity with Apple M1 ?

Open ruizalexandre opened this issue 3 years ago • 8 comments

Do you have a solution to run this docker image on Apple M1 ? :)

I know, it's not direct a problem of your image. But I'd like to know if you have a simple solution ☺️

Thanks.

ruizalexandre avatar May 03 '21 13:05 ruizalexandre

So far I stumbled upon an issue that Android emulators are not supported on Linux ARM. And when I worked around some issue I stumbled on https://github.com/741g/android-emulator-m1-preview/issues/14.

Seems we'll need to wait until emulators are officially supported on ARM Linux and can be installed via sdkmanager emulator

fkorotkov avatar May 10 '21 03:05 fkorotkov

Perfect ! Thank you for your work and your time !! 🚀

ruizalexandre avatar May 10 '21 07:05 ruizalexandre

I saw there is now an official emulator here: https://github.com/google/android-emulator-m1-preview

And in the readme it says in big text:

Note: No longer needed Support for downloading the M1-based emulator was added to SDK Manager, so it's not necessary to go to the Github > releases page to download a standalone .app anymore. In AVD Manager go to the Other Images tab as by default it doesn't show the ARM64 images.

Is there still anything blocking now?

acoutts avatar Jul 01 '21 12:07 acoutts

cc @fkorotkov @ruizalexandre @ened @westy92 is there any chance for an update?

acoutts avatar Jul 23 '21 10:07 acoutts

The problem there is that M1 emulators won't work since we need the emulators for Arm Linux since the Docker images is based of linux. I haven't seen any updates around Arm Linux emulators unfortunetly.

fkorotkov avatar Jul 23 '21 14:07 fkorotkov

Thanks @fkorotkov - I see now. We will just have to wait then.

acoutts avatar Jul 28 '21 12:07 acoutts

Hello, there have been updates on this point?

In my case I would only like to have the arm64 version of the image, so that trivial static analysis operations don't fail because of QEMU exceptions.

neokree avatar Oct 08 '22 14:10 neokree

I get ״qemu: uncaught target signal 6 (Aborted) - core dumped״.

I even tried to build the cirrusci/android-sdk:30 and cirrusci/android-sdk:tools images myself and then build a flutter image but I still had to use --platform linux/amd64 because without that I would get "qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory" then I built with --platform linux/amd64 and it gave me again "qemu: uncaught target signal 6 (Aborted) - core dumped ".

Unfortunately without it I can't do any flutter command like "flutter build ..." with docker, Any news on this?

shlomo-shalev avatar Oct 27 '22 08:10 shlomo-shalev

+1

liu731 avatar Dec 30 '22 08:12 liu731

Also flutter build web:

#22 50.57 si_signo=Segmentation fault(11), si_code=1, si_addr=0x7
#22 50.57 version=2.18.6 (stable) (Tue Dec 13 21:15:14 2022 +0000) on "linux_x64"
#22 50.57 pid=204, thread=212, isolate_group=dartdev(0x4003061000), isolate=dartdev(0x40030ca000)
#22 50.57 isolate_instructions=ffffab806000, vm_instructions=4001ed1580

...Unknown symbol stuff

#22 50.58 qemu: uncaught target signal 6 (Aborted) - core dumped
#22 50.59 /build/flutter/bin/internal/shared.sh: line 24:   204 Aborted                 "$DART" __deprecated_pub upgrade "$VERBOSITY" --no-precompile
#22 50.59 Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (1 tries left)
#22 55.62 Command 'pub upgrade' still failed after 10 tries, giving up.

yikerman avatar Jan 15 '23 12:01 yikerman

I found a workaround by manually install Flutter Linux:

FROM ubuntu:latest

RUN apt-get update && \
    apt-get install -y curl git wget unzip
RUN git clone --depth=1 --branch=stable https://github.com/flutter/flutter.git /usr/local/flutter
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"
RUN flutter channel stable && flutter upgrade
# Thus Flutter is installed

yikerman avatar Jan 15 '23 14:01 yikerman

I found a workaround by manually install Flutter Linux:

FROM ubuntu:latest

RUN apt-get update && \
    apt-get install -y curl git wget unzip
RUN git clone --depth=1 --branch=stable https://github.com/flutter/flutter.git /usr/local/flutter
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"
RUN flutter channel stable && flutter upgrade
# Thus Flutter is installed

The problem is not with installation flutter into image. Run flutter command creates error. Try after installation run "flutter build ..." or after starting container run "flutter start ..."

shlomo-shalev avatar Jan 15 '23 14:01 shlomo-shalev

@shlomo-shalev In my case I built web in the container using

RUN flutter build web --release

And it succeeded.

yikerman avatar Jan 15 '23 14:01 yikerman

@shlomo-shalev In my case I built web in the container using

RUN flutter build web --release

And it succeeded.

At macbook m1???

shlomo-shalev avatar Jan 15 '23 14:01 shlomo-shalev

@shlomo-shalev

At macbook m1???

Yes. However I haven't tried other platforms like linux.

yikerman avatar Jan 15 '23 15:01 yikerman

On a side note, for Apple Silicon devices you can try using our Tart virtualization. Our Xcode VM images are much larger than Docker images but they contain everything for building Flutter applications:

brew install cirruslabs/cli/tart
tart clone ghcr.io/cirruslabs/macos-ventura-xcode:latest ventura-xcode
tart run ventura-xcode

fkorotkov avatar Jan 15 '23 15:01 fkorotkov

Building an amd64 container on Apple Silicon doesn't work, but if you're building an arm64 container then it will work. I'm not sure about android/web, but it works for building Linux Desktop (only arm64). Unfortunately, Flutter don't support building amd64 on arm64 or vice-versa so I gave up on this and finally went with this example (Doesn't work on Apple Silicon but I needed it mainly for a GitHub action). Here is the working Dockerfile of what I previously did if anyone is interested.

flutter doctor works on Linux arm64 (I've tested), I'd love to know if android and web builds work as well if anyone tests this out.

I don't understand why flutter doctor fails on an amd64 container built on arm64. Can someone explain this? Is it a bug with Flutter?

# Use Ubuntu as the base image
FROM ubuntu:latest

# Install dependencies
RUN apt-get update && \
    apt-get install -y \
        build-essential \
        clang \
        cmake \
        curl \
        git \
        libffi-dev \
        libglu1-mesa \
        libgtk-3-dev \
        libssl-dev \
        libstdc++6 \
        libxml2 \
        ninja-build \
        pkg-config \
        unzip \
        xz-utils

# Specify the Flutter version
ENV FLUTTER_VERSION 3.16.5

# Download and install Flutter
RUN git clone https://github.com/flutter/flutter.git -b $FLUTTER_VERSION --depth 1 /flutter && \
    /flutter/bin/flutter config --no-analytics && \
    /flutter/bin/flutter precache

# Add Flutter to the PATH
ENV PATH="${PATH}:/flutter/bin"

# Verify Flutter installation
RUN flutter doctor

# Set the working directory
WORKDIR /app

# Copy the flutter application
COPY . .

# Get dependencies
RUN flutter pub get

# Entry point command to run the container
CMD ["bash"]

therealsujitk avatar Jan 03 '24 05:01 therealsujitk