I am new for dockerization of flutter project , Can someone please tell how to dockerize the flutter project

I am new for dockerization of flutter project , Can someone please tell how to dockerize the flutter project .

image

Can you share the content of your Dockerfile?

Generally, a sample Dockerfile look something like this:


FROM ubuntu:latest

RUN apt-get update
RUN apt-get install -y curl git unzip zip
RUN curl https://storage.googleapis.com/flutter_infra/releases/stable/linux/flutter_linux_1.22.2-stable.tar.xz | tar -xf -
ENV PATH "$PATH:/flutter/bin"

COPY . /app
WORKDIR /app


RUN flutter build apk --release


CMD ["flutter", "run"]

You can build Flutter Docker Image by running the below command:

docker build -t flutter-app .

Finally, running the Flutter container:

docker run -it --rm -p 8080:8080 flutter-app

Hi Ajeet ,
Thanks for response . I am using this basic file. Getting the same error. Can you please guide
FROM ubuntu:latest

RUN apt-get update

RUN apt-get install -y curl git unzip zip

#RUN curl https://storage.googleapis.com/flutter_infra/releases/stable/linux/flutter_linux_1.22.2-stable.tar.xz | tar -xf -

#RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback lib32stdc++6 python3

ENV PATH “$PATH:/flutter/bin”

COPY . /app

WORKDIR /app

RUN flutter build web

CMD [“flutter”, “run”]

Hi Team,

Flutter project taking so longer to build , tried many time . Can you please suggest me ?

hello, I have been trying for days I couldn’t solve it.
I used this command with docker in linux but I got conflict of version like this:

RUN curl -O https://storage.googleapis.com/flutter_infra/releases/stable/linux/flutter_linux_1.22.2-stable.tar.xz \
    && tar xf flutter_linux_1.22.2-stable.tar.xz \
    && rm flutter_linux_1.22.2-stable.tar.xz 
---------------------------------------------------------------------------------------
 [6/6] RUN flutter build apk --release:                                                                                                                                                               
0.567    Woah! You appear to be trying to run flutter as root.                                                                                                                                          
0.567    We strongly recommend running the flutter tool without superuser privileges.                                                                                                                   
0.567   /                                                                                                                                                                                               
0.567 📎                                                                                                                                                                                                
0.584 fatal: detected dubious ownership in repository at '/flutter'
0.584 To add an exception for this directory, call:
0.584 
0.584   git config --global --add safe.directory /flutter
0.605 Building flutter tool...
49.45 Running "flutter pub get" in app...                             
50.05 The current Dart SDK version is 2.10.2.
50.05 
50.05 
50.05 
50.05 Because horoscope requires SDK version >=2.19.0 <3.19.4, version solving failed.
50.13 pub get failed (1; Because horoscope requires SDK version >=2.19.0 <3.19.4, version solving failed.)

Can anyone help me?

hello, I have been trying for days I couldn’t solve it.
I used this command with docker in linux but I got conflict of version like this:

RUN curl -O https://storage.googleapis.com/flutter_infra/releases/stable/linux/flutter_linux_1.22.2-stable.tar.xz \
    && tar xf flutter_linux_1.22.2-stable.tar.xz \
    && rm flutter_linux_1.22.2-stable.tar.xz 
---------------------------------------------------------------------------------------
 [6/6] RUN flutter build apk --release:                                                                                                                                                               
0.567    Woah! You appear to be trying to run flutter as root.                                                                                                                                          
0.567    We strongly recommend running the flutter tool without superuser privileges.                                                                                                                   
0.567   /                                                                                                                                                                                               
0.567 📎                                                                                                                                                                                                
0.584 fatal: detected dubious ownership in repository at '/flutter'
0.584 To add an exception for this directory, call:
0.584 
0.584   git config --global --add safe.directory /flutter
0.605 Building flutter tool...
49.45 Running "flutter pub get" in app...                             
50.05 The current Dart SDK version is 2.10.2.
50.05 
50.05 
50.05 
50.05 Because horoscope requires SDK version >=2.19.0 <3.19.4, version solving failed.
50.13 pub get failed (1; Because horoscope requires SDK version >=2.19.0 <3.19.4, version solving fa

[/quote]