I've similar problem with you. It's because the "flutter" inside your container can't read & write your project due to the user permission that you've created in your Dockerfile (developer
).
My solution is run the docker using root
user. You can do:
chmod a+x /home/developer/flutter
and after you do RUN git clone https://github.com/flutter/flutter.git
to make sure flutter is accessible by all users and executabledocker run --rm -it -v "param1":"param2" -w "param2" -u 0 flutter_image flutter pub get
. param1
is your flutter project directory, param2
is volume that will be mounted on the docker's container, -u 0
means you perform flutter as root
user. For example docker run --rm -it -v "/home/user/flutter_project":"/home/developer/project1" -w "/home/developer/project1" -u 0 flutter_image flutter pub get
Or you can create docker-compose.yml
inside your flutter project:
services:
flutter:
image: flutter:3.19.6
user: root
volumes:
- .:/home/developer/project1
working_dir: /home/developer/project1
entrypoint: ["sh","-c","flutter build apk --split-per-abi"]
then run it by using docker compose up
, make sure you run the command inside your flutter project directory.
Feel free to reply if you're still facing the problem