build: add ENABLE_ANALYTICS to entrypoint

This commit is contained in:
Eligio Mariño
2023-03-19 17:00:52 +01:00
parent d26664bc6e
commit e506c4d581
5 changed files with 32 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
FLUTTER_VERSION=3.7.7
ANDROID_BUILD_TOOLS_VERSION=30.0.3
PLATFORMS_VERSIONS=28 31 33
ENABLE_ANALYTICS=true
+4
View File
@@ -69,6 +69,10 @@ RUN git clone --depth 1 --branch "$flutter_version" https://github.com/flutter/f
&& flutter config --no-enable-macos-desktop \
&& flutter doctor
COPY ./docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT [ "/docker-entrypoint.sh" ]
FROM flutter as android
LABEL org.opencontainers.image.source="https://github.com/gmeligio/flutter-docker-image" \
+6
View File
@@ -5,6 +5,8 @@ services:
target: flutter
args:
flutter_version: $FLUTTER_VERSION
environment:
ENABLE_ANALYTICS: $ENABLE_ANALYTICS
android:
build:
@@ -14,6 +16,8 @@ services:
flutter_version: $FLUTTER_VERSION
android_build_tools_version: $ANDROID_BUILD_TOOLS_VERSION
platforms_versions: $PLATFORMS_VERSIONS
environment:
ENABLE_ANALYTICS: $ENABLE_ANALYTICS
test:
build:
@@ -23,4 +27,6 @@ services:
flutter_version: $FLUTTER_VERSION
android_build_tools_version: $ANDROID_BUILD_TOOLS_VERSION
platforms_versions: $PLATFORMS_VERSIONS
environment:
ENABLE_ANALYTICS: $ENABLE_ANALYTICS
working_dir: /home/flutter/test_app/android
+13
View File
@@ -0,0 +1,13 @@
#!/bin/sh
analytic_tools_str="Dart and Flutter"
if [ "$ENABLE_ANALYTICS" = "true" ]; then
echo "Received 'ENABLE_ANALYTICS=true'.\nEnabling analytics for $analytic_tools_str."
dart --enable-analytics
flutter config --analytics
else
echo "Analytics are opt-in and disabled by default in $analytic_tools_str.\nTo enable analytics, pass the environment variable 'ENABLE_ANALYTICS=true' when starting the container."
fi
exec "$@"
+5
View File
@@ -1,5 +1,10 @@
# Docker image for Flutter
## Features
- [x] Analytics disabled by default
- [x] Minimal image to run flutter for Android platform in CI
## Alpha stability
This package is experimental and it's in active development