From 6cbb2d9eff389d656d402469aac520e1ec6dd0e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eligio=20Mari=C3=B1o?= <22875166+gmeligio@users.noreply.github.com> Date: Sat, 22 Jul 2023 11:39:51 +0200 Subject: [PATCH] fix: remove ecr registry --- .github/workflows/build_push_image.yml | 41 ------ .github/workflows/update_latest_version.yml | 3 +- docs/ecr.md | 148 -------------------- docs/readme.md | 12 +- docs/src/content.mdx | 14 +- docs/src/ecr.mdx | 3 - docs/src/package.json | 3 +- script/docker-entrypoint.sh | 4 +- 8 files changed, 19 insertions(+), 209 deletions(-) delete mode 100644 docs/ecr.md delete mode 100644 docs/src/ecr.mdx diff --git a/.github/workflows/build_push_image.yml b/.github/workflows/build_push_image.yml index 1751230..74b1c3e 100644 --- a/.github/workflows/build_push_image.yml +++ b/.github/workflows/build_push_image.yml @@ -15,21 +15,12 @@ jobs: contents: read runs-on: ubuntu-latest env: - AWS_REGION: us-east-1 IMAGE_REPOSITORY_NAME: flutter-android ANDROID_BUILD_TOOLS_VERSION: 30.0.3 - # ANDROID_PLATFORM_VERSIONS: 28 31 33 steps: - name: Checkout repository uses: actions/checkout@v3 - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ env.AWS_REGION }} - - name: Login to Docker Hub uses: docker/login-action@v2 with: @@ -50,34 +41,6 @@ jobs: username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_ROBOT_TOKEN }} - - name: Login to ECR Public - uses: docker/login-action@v2 - with: - # AWS_REGION needs to be defined in the parent scope - registry: public.ecr.aws - username: ${{ secrets.AWS_ACCESS_KEY_ID }} - password: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - - - name: Create ECR repository for final images - uses: int128/create-ecr-repository-action@v1 - id: ecr - with: - public: true - repository: ${{ env.IMAGE_REPOSITORY_NAME }} - - - name: Update description of ECR repository for final images - run: | - aws ecr-public put-repository-catalog-data \ - --repository-name ${{ env.IMAGE_REPOSITORY_NAME }} \ - --catalog-data "description"="${{ github.event.repository.description }}",usageText="See About section",aboutText="$(jq -nRs 'input' docs/ecr.md | sed 's/\\n/\n/g')" - - - name: Create ECR repository for layer cache - uses: int128/create-ecr-repository-action@v1 - id: ecr-cache - with: - public: true - repository: ${{ env.IMAGE_REPOSITORY_NAME }}/cache - - name: Set environment variables from from version.json run: | echo "FLUTTER_VERSION=$(jq -r '.flutter.version' config/version.json)" >> $GITHUB_ENV @@ -100,7 +63,6 @@ jobs: ${{ env.IMAGE_REPOSITORY_PATH }} ghcr.io/${{ env.IMAGE_REPOSITORY_PATH }} quay.io/${{ env.IMAGE_REPOSITORY_PATH }} - public.ecr.aws/${{ env.IMAGE_REPOSITORY_PATH }} tags: | type=raw,value=${{ env.FLUTTER_VERSION }} @@ -132,9 +94,6 @@ jobs: uses: docker/build-push-action@v4 with: push: true - # TODO: Use ECR for cache after this issue is solved https://github.com/aws/containers-roadmap/issues/876 - # cache-from: ${{ steps.ecr-cache.outputs.repository-uri }}:cache - # cache-to: ${{ steps.ecr-cache.outputs.repository-uri }}:cache cache-from: ${{ env.CACHE_REPOSITORY_PATH }}:cache cache-to: ${{ env.CACHE_REPOSITORY_PATH }}:cache tags: ${{ steps.metadata.outputs.tags }} diff --git a/.github/workflows/update_latest_version.yml b/.github/workflows/update_latest_version.yml index 4f1dc7b..6fb24c6 100644 --- a/.github/workflows/update_latest_version.yml +++ b/.github/workflows/update_latest_version.yml @@ -59,8 +59,7 @@ jobs: working-directory: docs/src run: | npm ci --prefer-offline - npm run readme - npm run ecr + npm run build - name: Create pull request if there are changes uses: peter-evans/create-pull-request@v5 diff --git a/docs/ecr.md b/docs/ecr.md deleted file mode 100644 index 6ba43d9..0000000 --- a/docs/ecr.md +++ /dev/null @@ -1,148 +0,0 @@ - - -# Flutter Docker Image - -Docker images for Flutter Continuous Integration (CI). The source is available [on GitHub](https://github.com/gmeligio/flutter-docker-image). - -The images includes the minimum tools to run Flutter and build apps. The versions of the tools installed are based on the official [Flutter](https://github.com/flutter/flutter) repository. The final goal is that Flutter doesn't need to download anything like tools or SDKs when running the container. - -Features: - -* \[x\] Analytics disabled by default, opt-in suggested in the Docker entrypoint. -* \[x\] Rootless user, default user is flutter:flutter -* \[x\] Cached Fastlane gem -* \[ \] Minimal image to run Flutter in Continuous Integration (CI): - * \[x\] Android - * \[ \] iOS - * \[ \] Linux - * \[ \] Windows - * \[ \] Web - -## Running containers - -On the terminal: - -```bash -# From Docker Hub -docker run --rm -it gmeligio/flutter-android:3.10.5 bash - -# From GitHub Container Registry -docker run --rm -it ghcr.io/gmeligio/flutter-android:3.10.5 bash - -# From Quay.io -docker run --rm -it quay.io/gmeligio/flutter-android:3.10.5 bash - -# From AWS ECR -docker run --rm -it public.ecr.aws/gmeligio/flutter-android:3.10.5 bash -``` - -On a workflow in GitHub Actions: - -```yaml -jobs: - build: - runs-on: ubuntu-22.04 - container: - image: ghcr.io/gmeligio/flutter-android:3.10.5 - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Build - run: flutter build apk -``` - -On a `.gitlab-ci.yml` in GitLab CI: - -```yaml -build: - image: ghcr.io/gmeligio/flutter-android:3.10.5 - script: - - flutter build apk -``` - -Fastlane (see guide https://docs.fastlane.tools): - -```bash -# Ruby bundler is available in the container. -# The fastlane gem is cached but not installed - -# Use --prefer-local to download gems only if they are not cached -bundle install --prefer-local -bundle exec fastlane -``` - -## Versions - -There is no `latest` Docker tag on purpose. You need to specify the version of the image you want to use. The reason for that is that `latest` is a dynamic tag that can be confusing when reading the image URI because doesn't necessarily point to the latest image built and can cause unexpected behavior when rerunning a past CI job that runs with an overwritten latest tags. There are multiple articles explaining more about this reasoning like [What's Wrong With The Docker :latest Tag?](https://vsupalov.com/docker-latest-tag/) and [The misunderstood Docker tag: latest](https://medium.com/@mccode/the-misunderstood-docker-tag-latest-af3babfd6375). - -The tag is composed of the Flutter version used to build the image. For example: - -* Docker image: gmeligio/flutter-android:3.10.5 -* Flutter version: 3.10.5 - -### flutter-android - -Versions used in latest image gmeligio/flutter-android:3.10.5: - -* Flutter: 3.10.5 -* Android SDK Platforms: 33 -* Gradle: 7.5 -* Fastlane: 2.213.0 - -Registries: - -* https://hub.docker.com/r/gmeligio/flutter-android -* https://github.com/gmeligio/flutter-docker-image/pkgs/container/flutter-android -* https://quay.io/repository/gmeligio/flutter-android -* https://gallery.ecr.aws/gmeligio/flutter-android - -## Alpha stability - -The images are experimental and are in active development. They are being used for small projects but there is no confirmation of production usage yet. - -## Developing locally - -### Running the container - -The Dockerfile expects a few parameters: - -* `flutter_version `: The version of Flutter to use when building. Example: 3.10.5 -* `android_build_tools_version `: The version of the Android SDK Build Tools to install. Example: 30.0.3 -* `android_platform_versions `: The versions of the Android SDK Platforms to install, separated by spaces. Example: 28 31 33 - -```bash -# Android -docker build --target android --build-arg flutter_version=3.7.4 fastlane_version=2.213.0 android_build_tools_version=30.0.3 --build-arg android_platform_versions="28 31 33" -t android-test . -``` - -### Dockerfile stages - -The base image is `debian/debian:11-slim` and from there multiple stages are created: - -1. `flutter` stage hast only the dependencies required to install flutter and common tools used by flutter internal commands, like `git`. -2. `android` stage has the dependencies required to install the Android SDK and to develop Flutter apps for Android. -3. `android-test` stage is for testing purposes. It creates a Flutter app and checks that the can be build for Android. - -## TODO - -1. Android: - * Android emulator - * Android NDK - -## Other Docker projects for mobile development - -* https://github.com/softartdev/docker-android-fastlane - -## Acknowledgments - -* https://github.com/mingchen/docker-android-build-box -* https://github.com/gmemstr/flutter-fastlane-android -* https://github.com/circleci/circleci-images -* https://github.com/cirruslabs/docker-images-android -* https://github.com/cirruslabs/docker-images-flutter -* https://github.com/instrumentisto/flutter-docker-image -* https://github.com/fischerscode/DockerFlutter - -## License - -[MIT License](../LICENSE) \ No newline at end of file diff --git a/docs/readme.md b/docs/readme.md index 72367f4..16e458b 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -11,7 +11,7 @@ The images includes the minimum tools to run Flutter and build apps. The version Features: * \[x\] Analytics disabled by default, opt-in suggested in the Docker entrypoint. -* \[x\] Rootless user, default user is flutter:flutter +* \[x\] Rootless user `flutter:flutter`, with permissions to run on GitLab CI. * \[x\] Cached Fastlane gem * \[ \] Minimal image to run Flutter in Continuous Integration (CI): * \[x\] Android @@ -33,9 +33,6 @@ docker run --rm -it ghcr.io/gmeligio/flutter-android:3.10.5 bash # From Quay.io docker run --rm -it quay.io/gmeligio/flutter-android:3.10.5 bash - -# From AWS ECR -docker run --rm -it public.ecr.aws/gmeligio/flutter-android:3.10.5 bash ``` On a workflow in GitHub Actions: @@ -96,7 +93,6 @@ Registries: * https://hub.docker.com/r/gmeligio/flutter-android * https://github.com/gmeligio/flutter-docker-image/pkgs/container/flutter-android * https://quay.io/repository/gmeligio/flutter-android -* https://gallery.ecr.aws/gmeligio/flutter-android ## Alpha stability @@ -131,6 +127,12 @@ The base image is `debian/debian:11-slim` and from there multiple stages are cre * Android emulator * Android NDK +## FAQ + +### Why not push to AWS ECR Public registry? + +The storage of the images starts to cost after 50 GB and increases with every pushed image because the AWS Free Tier covers up to 50 GB of total storage for free in ECR Public. + ## Other Docker projects for mobile development * https://github.com/softartdev/docker-android-fastlane diff --git a/docs/src/content.mdx b/docs/src/content.mdx index db84aec..4d7f1a3 100644 --- a/docs/src/content.mdx +++ b/docs/src/content.mdx @@ -13,7 +13,7 @@ The images includes the minimum tools to run Flutter and build apps. The version Features: - [x] Analytics disabled by default, opt-in suggested in the Docker entrypoint. -- [x] Rootless user, default user is flutter:flutter +- [x] Rootless user `flutter:flutter`, with permissions to run on GitLab CI. - [x] Cached Fastlane gem - [ ] Minimal image to run Flutter in Continuous Integration (CI): - [x] Android @@ -33,10 +33,7 @@ docker run --rm -it ${imageUri} bash docker run --rm -it ghcr.io/${imageUri} bash # From Quay.io -docker run --rm -it quay.io/${imageUri} bash - -# From AWS ECR -docker run --rm -it public.ecr.aws/${imageUri} bash`} +docker run --rm -it quay.io/${imageUri} bash`} On a workflow in GitHub Actions: @@ -91,7 +88,6 @@ Registries: - https://hub.docker.com/r/{repositoryPath} - https://github.com/gmeligio/flutter-docker-image/pkgs/container/flutter-android - https://quay.io/repository/{repositoryPath} -- https://gallery.ecr.aws/{repositoryPath} ## Alpha stability @@ -124,6 +120,12 @@ The base image is `debian/debian:11-slim` and from there multiple stages are cre - Android emulator - Android NDK +## FAQ + +### Why not push to AWS ECR Public registry? + +The storage of the images starts to cost after 50 GB and increases with every pushed image because the AWS Free Tier covers up to 50 GB of total storage for free in ECR Public. + ## Other Docker projects for mobile development - https://github.com/softartdev/docker-android-fastlane diff --git a/docs/src/ecr.mdx b/docs/src/ecr.mdx deleted file mode 100644 index aad70f5..0000000 --- a/docs/src/ecr.mdx +++ /dev/null @@ -1,3 +0,0 @@ -import Content from './content.mdx' - - diff --git a/docs/src/package.json b/docs/src/package.json index 20e56f6..c0c080d 100644 --- a/docs/src/package.json +++ b/docs/src/package.json @@ -4,9 +4,8 @@ "description": "", "main": "index.js", "scripts": { - "build": "npm run readme && npm run ecr", + "build": "npm run readme", "readme": "cross-env NODE_ENV=production mdx-to-md readme.mdx ../readme.md", - "ecr": "cross-env NODE_ENV=production mdx-to-md ecr.mdx ../ecr.md", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", diff --git a/script/docker-entrypoint.sh b/script/docker-entrypoint.sh index dda454e..26937b7 100644 --- a/script/docker-entrypoint.sh +++ b/script/docker-entrypoint.sh @@ -3,7 +3,7 @@ analytic_tools_str="Dart, Flutter and Fastlane" if [ "$ENABLE_ANALYTICS" = "true" ]; then - echo "Received 'ENABLE_ANALYTICS=true'.\nEnabling analytics for $analytic_tools_str." + echo -e "Received 'ENABLE_ANALYTICS=true'.\nEnabling analytics for $analytic_tools_str." dart --enable-analytics flutter config --analytics @@ -11,7 +11,7 @@ if [ "$ENABLE_ANALYTICS" = "true" ]; then # export COCOAPODS_DISABLE_STATS=1 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." + echo -e "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 "$@"