From e506c4d58117341d089ae7114f637a7f80c2922a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eligio=20Mari=C3=B1o?= Date: Sun, 19 Mar 2023 17:00:52 +0100 Subject: [PATCH] build: add ENABLE_ANALYTICS to entrypoint --- .env.example | 4 ++++ Dockerfile | 4 ++++ docker-compose.yml | 6 ++++++ docker-entrypoint.sh | 13 +++++++++++++ readme.md | 5 +++++ 5 files changed, 32 insertions(+) create mode 100644 .env.example create mode 100644 docker-entrypoint.sh diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..a5c9eef --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +FLUTTER_VERSION=3.7.7 +ANDROID_BUILD_TOOLS_VERSION=30.0.3 +PLATFORMS_VERSIONS=28 31 33 +ENABLE_ANALYTICS=true diff --git a/Dockerfile b/Dockerfile index c4a81a4..a415692 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" \ diff --git a/docker-compose.yml b/docker-compose.yml index 5d83494..591e2e0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..d248563 --- /dev/null +++ b/docker-entrypoint.sh @@ -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 "$@" diff --git a/readme.md b/readme.md index e1b458c..fb5de46 100644 --- a/readme.md +++ b/readme.md @@ -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