cirruslabs / docker-images-flutter

Docker Images for Flutter
MIT License
454 stars 139 forks source link

Doesn't work as non-root user #123

Open parched opened 3 years ago

parched commented 3 years ago

I'm trying to use this in gitpod, where there is a non-root user, but it fails with

Flutter failed to open a file at "/sdks/flutter/bin/cache/lockfile". The flutter tool cannot access the file.
Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user.

I just added

RUN chmod -R a+w $FLUTTER_HOME

to fix it, but I'm not sure if there is a better solution.

fkorotkov commented 3 years ago

Could you please provide a bit more details about gitpod and how it's configured for you?

parched commented 3 years ago

Gitpod is a cloud IDE which gives you a shell in a docker instance. You can specify the Dockerfile, e.g., I'm trying this one. The user it gives you is not the root user, but gitpod.

You can try it here if you like http://gitpod.io/#https://github.com/parched/strain-gauge/commit/cfde495f0160ca4a3e533373cd2b1b3acb78e66f

fkorotkov commented 3 years ago

I think it's a question for the GitPod folks. If you can use a custom Dockerfile then you probably can try the following one:

FROM cirrusci/flutter:stable

USER gitpod
RUN chmod -R a+w $FLUTTER_HOME

🤷

lidholm commented 2 years ago

I have a similar issue. I am trying to use this image with dagger.io. It works well if I run my commands as root, but I get a warning from flutter saying that I shouldn't Running it as a different user doesn't work I got the same error around the lockfile, if I remove it I get Flutter failed to check for directory existence at "/root/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-31.0.0/lib/". instead

Maybe I shouldn't use this image, but wanted to let it be known at least

8thgencore commented 11 months ago

I have the same mistake when I launch pipeline not from root

* What went wrong:
Could not determine the dependencies of task ':app:lintVitalReportStagingRelease'.
> Failed to install the following SDK components:
      build-tools;30.0.3 Android SDK Build-Tools 30.0.3
      tools Android SDK Tools
      emulator Android Emulator
      platforms;android-34 Android SDK Platform 34
  The SDK directory is not writable (/opt/android-sdk-linux)
gmeligio commented 11 months ago

If I can suggest a different image, I created a repo for Flutter images that uses non-root use by default. It was also to solve other issues like preaching Android SDK, etc. After trying many existing images like this repository and others, I couldn't find one to fit my needs. @8thgencore, give it a try if you can. It would be nice if some of the things I did could be contributed to this repo, but I wanted to try a different approach, so I created a separate repo.

beroso commented 2 months ago

I just added

RUN chmod -R a+w $FLUTTER_HOME

to fix it, but I'm not sure if there is a better solution.

I'm using the following approach:

RUN chown -R $MY_USER:$MY_USER $FLUTTER_HOME