fix: remove ecr registry

This commit is contained in:
Eligio Mariño
2023-07-22 11:39:51 +02:00
parent aecf655766
commit 6cbb2d9eff
8 changed files with 19 additions and 209 deletions
-41
View File
@@ -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 }}
+1 -2
View File
@@ -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
-148
View File
@@ -1,148 +0,0 @@
<!--- This markdown file was auto-generated from "ecr.mdx" -->
# 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 <string>`: The version of Flutter to use when building. Example: 3.10.5
* `android_build_tools_version <string>`: The version of the Android SDK Build Tools to install. Example: 30.0.3
* `android_platform_versions <list>`: 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)
+7 -5
View File
@@ -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
+8 -6
View File
@@ -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`}
</code></pre>
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
-3
View File
@@ -1,3 +0,0 @@
import Content from './content.mdx'
<Content/>
+1 -2
View File
@@ -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": "",
+2 -2
View File
@@ -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 "$@"