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:

How To Create Heatmaps In Javascript: Exploring The Heat Js Library

How to create heatmaps in JavaScript: The Heat.js library

This tutorial will explore the application of heatmaps in JavaScript projects, focusing on how to use the Heat.js library to generate them.

Oghenetega Denedo
May 8, 2024 â‹… 7 min read
Eleventy Adoption Guide: Overview, Examples, And Alternatives

Eleventy adoption guide: Overview, examples, and alternatives

Eleventy (11ty) is a compelling solution for developers seeking a straightforward, performance-oriented approach to static site generation.

Nelson Michael
May 7, 2024 â‹… 8 min read
6 CSS Tools For More Efficient And Flexible CSS Handling

6 CSS tools for more efficient and flexible CSS handling

Explore some CSS tools that offer the perfect blend of efficiency and flexibility when handling CSS, such as styled-components and Emotion.

Fimber Elemuwa
May 7, 2024 â‹… 7 min read
Leveraging React Server Components In Redwoodjs

Leveraging React Server Components in RedwoodJS

RedwoodJS announced support for server-side rendering and RSCs in its Bighorn release. Explore this feature for when it’s production-ready.

Stephan Miller
May 6, 2024 â‹… 9 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