From 8247f81ed499b8d96dde15a52e614b8d25d165f9 Mon Sep 17 00:00:00 2001 From: tyranron Date: Fri, 5 Nov 2021 11:21:54 +0100 Subject: [PATCH] Version by Android SDK explicitly --- CHANGELOG.md | 15 +++++++++++++++ Dockerfile | 42 ++++++++++++++++++++++++++++++------------ Makefile | 5 ++++- README.md | 7 ++++--- tests/main.bats | 24 ++++++++++++++++++++++++ 5 files changed, 77 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61ca02b..86df5b4 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,20 @@ All user visible changes to this project will be documented in this file. This p +## [2.5.3-androidsdk30-r0] · 2021-11-05 +[2.5.3-androidsdk30-r0]: /../../tree/2.5.3-androidsdk30-r0 + +[Diff](/../../compare/2.5.3-r0...2.5.3-androidsdk30-r0) + +### Added + +- Explicitly versioning for [Android SDK]. +- `Web` [Flutter] toolchain supported. +- Prefetched tools for supported [Flutter] toolchains. + + + + ## [2.5.3-r0] · 2021-11-04 [2.5.3-r0]: /../../tree/2.5.3-r0 @@ -18,5 +32,6 @@ All user visible changes to this project will be documented in this file. This p +[Android SDK]: https://developer.android.com/studio [Flutter]: https://flutter.dev [Semantic Versioning 2.0.0]: https://semver.org diff --git a/Dockerfile b/Dockerfile index 2008136..8faba6e 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,44 @@ -# https://hub.docker.com/r/cirrusci/flutter -# https://github.com/cirruslabs/docker-images-flutter/blob/master/sdk/Dockerfile -ARG flutter_ver=2.5.3 -FROM cirrusci/flutter:${flutter_ver} +# https://hub.docker.com/r/cirrusci/android-sdk +# https://github.com/cirruslabs/docker-images-android/blob/master/sdk/30/Dockerfile +ARG android_sdk_ver=30 +FROM cirrusci/android-sdk:${android_sdk_ver} +ARG flutter_ver=2.5.3 ARG build_rev=0 LABEL org.opencontainers.image.source="\ https://github.com/instrumentisto/flutter-docker-image" -# Install dependencies +# Install Flutter +ENV FLUTTER_HOME=/usr/local/flutter \ + FLUTTER_VERSION=${flutter_ver} \ + PATH=$PATH:/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin RUN apt-get update \ - && apt-get install -y --no-install-recommends \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --no-install-suggests \ + ca-certificates \ + && update-ca-certificates \ + \ + # Install dependencies for Linux toolchain + && apt-get install -y --no-install-recommends --no-install-suggests \ build-essential \ clang cmake \ lcov \ libgtk-3-dev liblzma-dev \ ninja-build \ pkg-config \ - # Cleanup unnecessary stuff - && rm -rf /var/lib/apt/lists/* - -# Enable Android and Linux support -RUN flutter config --enable-android \ - && flutter config --enable-linux-desktop + \ + # Install Flutter itself + && curl -fL -o /tmp/flutter.tar.xz \ + https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${flutter_ver}-stable.tar.xz \ + && tar -xf /tmp/flutter.tar.xz -C /usr/local/ \ + && flutter config --enable-android \ + --enable-linux-desktop \ + --enable-web \ + --no-enable-ios \ + && flutter precache --universal --linux --web --no-ios \ + && (yes | flutter doctor --android-licenses) \ + \ + && rm -rf /var/lib/apt/lists/* \ + /tmp/* diff --git a/Makefile b/Makefile index 4c99411..b70fda8 100755 --- a/Makefile +++ b/Makefile @@ -17,6 +17,8 @@ eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\ FLUTTER_VER ?= $(strip \ $(shell grep 'ARG flutter_ver=' Dockerfile | cut -d '=' -f2)) +ANDROID_SDK_VER ?= $(strip \ + $(shell grep 'ARG android_sdk_ver=' Dockerfile | cut -d '=' -f2)) BUILD_REV ?= $(strip \ $(shell grep 'ARG build_rev=' Dockerfile | cut -d '=' -f2)) @@ -24,7 +26,7 @@ NAMESPACES := instrumentisto \ ghcr.io/instrumentisto \ quay.io/instrumentisto NAME := flutter -TAGS ?= $(FLUTTER_VER)-r$(BUILD_REV) \ +TAGS ?= $(FLUTTER_VER)-androidsdk$(ANDROID_SDK_VER)-r$(BUILD_REV) \ $(FLUTTER_VER) \ $(strip $(shell echo $(FLUTTER_VER) | cut -d '.' -f1,2)) \ $(strip $(shell echo $(FLUTTER_VER) | cut -d '.' -f1)) \ @@ -72,6 +74,7 @@ docker.image: docker build --network=host --force-rm \ $(if $(call eq,$(no-cache),yes),--no-cache --pull,) \ --build-arg flutter_ver=$(FLUTTER_VER) \ + --build-arg android_sdk_ver=$(ANDROID_SDK_VER) \ --build-arg build_rev=$(BUILD_REV) \ -t instrumentisto/$(NAME):$(or $(tag),$(VERSION)) ./ diff --git a/README.md b/README.md index ce5f19f..39fdfb6 100755 --- a/README.md +++ b/README.md @@ -11,14 +11,14 @@ Flutter Docker image [Changelog](https://github.com/instrumentisto/flutter-docker-image/blob/master/CHANGELOG.md) -Based on [`cirrusci/flutter` Docker image][2]. +Based on [`cirrusci/android-sdk` Docker image][2]. ## Supported tags and respective `Dockerfile` links -- [`2.5.3-r0`, `2.5.3`, `2.5`, `2`, `latest`][201] +- [`2.5.3-androidsdk30-r0`, `2.5.3`, `2.5`, `2`, `latest`][201] @@ -27,6 +27,7 @@ Based on [`cirrusci/flutter` Docker image][2]. - `Android` - `Linux` +- `Web` @@ -107,7 +108,7 @@ If you have any problems with or questions about this image, please contact us t [DockerHub]: https://hub.docker.com [Flutter]: https://flutter.dev -[2]: https://hub.docker.com/r/cirrusci/flutter +[2]: https://hub.docker.com/r/cirrusci/android-sdk [80]: https://github.com/instrumentisto/flutter-docker-image/issues [90]: https://github.com/instrumentisto/flutter-docker-image diff --git a/tests/main.bats b/tests/main.bats index 7266fbe..ee55599 100755 --- a/tests/main.bats +++ b/tests/main.bats @@ -32,6 +32,23 @@ [ "$status" -eq 0 ] } +@test "flutter has correct version" { + run docker run --rm --entrypoint sh $IMAGE -c \ + "flutter --version | grep 'Flutter ' | cut -d ' ' -f 2 | tr -d ' '" + [ "$status" -eq 0 ] + [ "$output" != '' ] + actual="$output" + + run sh -c "cat Dockerfile | grep 'ARG flutter_ver=' \ + | cut -d '=' -f 2 \ + | tr -d ' '" + [ "$status" -eq 0 ] + [ "$output" != '' ] + expected="$output" + + [ "$actual" == "$expected" ] +} + @test "Android toolchain is enabled" { run docker run --rm --entrypoint sh $IMAGE -c \ @@ -59,3 +76,10 @@ [ "$status" -eq 0 ] [[ "$output" == *"[✓] Linux toolchain"* ]] } + + +@test "Web toolchain is enabled" { + run docker run --rm --entrypoint sh $IMAGE -c \ + 'flutter config | grep "enable-web: true"' + [ "$status" -eq 0 ] +}