79305315

Date: 2024-12-24 10:17:28
Score: 1
Natty:
Report link

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:

  1. Add 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 executable
  2. Then you can run docker 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

Reasons:
  • Whitelisted phrase (-1): solution is
  • Long answer (-1):
  • Has code block (-0.5):
  • Me too answer (2.5): 've similar problem
  • Low reputation (1):
Posted by: Arby Azra