2021-10-19
1486
#docker#flutter
Damilare Jolayemi
72066
Oct 19, 2021 ⋅ 5 min read

Containerizing Flutter web apps with Docker

Damilare Jolayemi Damilare is an enthusiastic problem-solver who enjoys building whatever works on the computer. He has a knack for slapping his keyboards till something works. When he's not talking to his laptop, you'll find him hopping on road trips and sharing moments with his friends, or watching shows on Netflix.

Recent posts:

Superglue Vs. Hotwire For Modern Frontend Development

Superglue vs. Hotwire for modern frontend development

Explore how Superglue and Hotwire revolutionize frontend development with HTML over the wire, enhancing performance, flexibility, and ease of use.

Frank Joseph
Jun 12, 2024 ⋅ 7 min read
Using Pocketbase To Build A Full Stack Application

Using PocketBase to build a full-stack application

PocketBase is a performant Go-based tool that comes with essential features like user auth, file uploads, access control rules, and more.

Rahul Padalkar
Jun 11, 2024 ⋅ 18 min read
The Top Tools For Implementing E-Commerce Search In React

The top tools for implementing e-commerce search in React

Explore top frontend tools for implementing e-commerce search functionality with React demo implementations.

Saleh Mubashar
Jun 10, 2024 ⋅ 7 min read
Signals Vs Ngonchanges For Better Angular State Management

Signals vs. ngOnChanges for better Angular state management

Angular is evolving in some exciting ways. Explore how signals enhance state management compared to the “old” approach using ngOnChanges.

Lewis Cianci
Jun 7, 2024 ⋅ 6 min read
View all posts

9 Replies to "Containerizing Flutter web apps with Docker"

  1. Hi, thanks for the great explanation on how to run flutter in a container, but I need to add something.

    In the Dockerfile
    1.) You need to remove the 1st line from “sh”
    2.) Add these 2 lines to the Docker file
    ENV TZ=Europe/Warsaw
    RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

    This is necessary because apt-get wants to install the “libgconf-2-4” package and tzdata and we need to answer the question about TIMEZONE during installation/configuration. These 2 lines in the Dockerfile can configure TIMEZONE automatically.

    Of course, we can also run nginx as a replacement with “python3 -m http.server $PORT” but that’s another story 🙂

    1. After which line do we have to add the below line in Dockerfile?

      ENV TZ=Europe/Warsaw
      RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

  2. ERROR: while running ` docker build -t flutter_web_test . `

    => ERROR [ 3/14] RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc 1.1s
    ——
    > [ 3/14] RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback lib32stdc++6 python3:
    #6 0.329 Reading package lists…
    #6 0.934 Building dependency tree…
    #6 1.060 Reading state information…
    #6 1.108 E: Unable to locate package lib32stdc++6
    #6 1.108 E: Couldn’t find any package by regex ‘lib32stdc++6’
    ——
    executor failed running [/bin/sh -c apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback lib32stdc++6 python3]: exit code: 100

  3. answer to why it is not working on M1
    As you noticed yourself, you are starting a docker build based on an image that was built for another platform, i.e. you are running arm64 but the image is linux/amd64. This means that docker will run it but with an emulation layer, namely qemu.

    Some incompatibility between Dart and qemu seems to be the problem. In the stacktrace you posted, qemu crashed when Dart runtime tried to execute InvokeCode(). This is actually a reported problem, see e.g.

    dart-lang github issue: Building linux/amd64 Docker Image on Mac M1 (most relevant, I think)
    flutter github: build flutter(3.0.3) docker image base on ubuntu:18.04 crash
    another flutter issue: Unable to ‘pub upgrade’ flutter tool
    answer to what to do
    The Dart folks have no plans to analyze this any further since the problem lies with qemu and the problem was not reproduced with qemu outside docker.

    It is also noteworthy that docker with qemu is only provided as a best effort and the docker project itself is unlikely to tackle the issue either, even if reported.

    I did not find a filed issue for qemu itself.

    There are basically two options:

    Do the thing without qemu, meaning to build in a linux/arm64 container
    This will work to some degree regarding flutter, but the next thing you will have to tackle is arm-based android build for linux, which is a whole new can of worms. See e.g. google’s android bug tracker, Please support Linux aarch64 for building apps and others.

    Do the build without arm/M1 hardware
    As sad as it is to realize this, it might be the straightforward solution to not cross-build in this case, at least for flutter with android build target. And likely also a logical one if you want to provide an intel compatible docker image to coworkers and/or CI which might not run M1. Ultimately, it is a question what your reference build platform is.

  4. It was working fine, but for some reason now I always get this error:

    exec /app/server/server.sh: no such file or directory

    Does anyone have a solution for that?

  5. Following steps to much time run

    => [ 3/14] RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback l 735.5s
    => => # questions will narrow this down by presenting a list of cities, representing
    => => # the time zones in which they are located.
    => => # 1. Africa 4. Australia 7. Atlantic 10. Pacific 13. Etc
    => => # 2. America 5. Arctic 8. Europe 11. SystemV
    => => # 3. Antarctica 6. Asia 9. Indian 12. US
    => => # Geographic area:

    Any Idea why it takes to much time?

  6. The above docker file is build around 1.92 GB flutter mage. Is there any way to reduce that image size?

Leave a Reply