我想在运行 Alpine Linux 的 Docker 容器上安装 Flutter。
我写了以下内容
Dockerfile
:
FROM alpine
RUN apk add bash curl file git zip
RUN git clone https://github.com/flutter/flutter.git
ENV PATH="$PATH:/flutter/bin"
RUN flutter channel stable
一切都很顺利,直到最后一步,我得到:
Step 5/5 : RUN flutter channel stable
---> Running in f8e764b1e091
Downloading Dart SDK from Flutter engine 82b4ae86d69b4bad10a42ad380f2a538d97ffb38...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 174M 100 174M 0 0 23.1M 0 0:00:07 0:00:07 --:--:-- 23.8M
Building flutter tool...
/flutter/bin/cache/dart-sdk/bin/pub: line 49: /flutter/bin/cache/dart-sdk/bin/dart: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (9 tries left)
/flutter/bin/cache/dart-sdk/bin/pub: line 49: /flutter/bin/cache/dart-sdk/bin/dart: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (8 tries left)
/flutter/bin/cache/dart-sdk/bin/pub: line 49: /flutter/bin/cache/dart-sdk/bin/dart: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (7 tries left)
/flutter/bin/cache/dart-sdk/bin/pub: line 49: /flutter/bin/cache/dart-sdk/bin/dart: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (6 tries left)
/flutter/bin/cache/dart-sdk/bin/pub: line 49: /flutter/bin/cache/dart-sdk/bin/dart: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (5 tries left)
/flutter/bin/cache/dart-sdk/bin/pub: line 49: /flutter/bin/cache/dart-sdk/bin/dart: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (4 tries left)
/flutter/bin/cache/dart-sdk/bin/pub: line 49: /flutter/bin/cache/dart-sdk/bin/dart: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (3 tries left)
/flutter/bin/cache/dart-sdk/bin/pub: line 49: /flutter/bin/cache/dart-sdk/bin/dart: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (2 tries left)
/flutter/bin/cache/dart-sdk/bin/pub: line 49: /flutter/bin/cache/dart-sdk/bin/dart: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (1 tries left)
Command 'pub upgrade' still failed after 10 tries, giving up.
The command '/bin/sh -c flutter channel stable' returned a non-zero code: 1
为什么?
我尝试过:
flutter doctor
而不是flutter channel stable
——仍然是同样的问题root
用户——仍然是同样的问题我在OP创建的问题中找到了一个可行的解决方案。只需将
gcompat
添加到您的包裹中即可。
Dockerfile
FROM alpine
RUN apk update
## Make sure to install gcompat
RUN apk add bash curl file git unzip which zip gcompat
# # download Flutter SDK from Flutter Github repo
RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter
# # Set flutter environment path
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"
# # Run flutter doctor
RUN flutter doctor
# # Enable flutter web
RUN flutter channel master
RUN flutter upgrade
RUN flutter config --enable-web