From 2330b10aa75b75873ac0d3225ed98c80f1b67944 Mon Sep 17 00:00:00 2001 From: Fmstrat Date: Mon, 2 Oct 2023 12:02:44 +0000 Subject: [PATCH 1/6] added auto-build of docker image --- .github/workflows/docker.yml | 50 ++++++++++++++++++++++++++++++++++++ DOCKER.md | 4 ++- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000000..d2cd5d29d9 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,50 @@ +name: Build and push docker + +on: + release: + types: [published] + +# Use the below to integrate into a Beta build from master +# Changes to the Dockerfile to use the manually built Jar +# from the build automation would be required. +# on: +# pull_request: +# branches: [master] +# types: [closed] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + + build_and_push: + name: Build and push + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Check out the repo + uses: actions/checkout@v3 + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Get Hash + id: hash + run: echo "GITHUB_HASH=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/arm64/v8 + file: ./docker/dockerfiles/seed.Dockerfile + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.GITHUB_HASH }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest diff --git a/DOCKER.md b/DOCKER.md index 372c3af94c..f162df27b1 100644 --- a/DOCKER.md +++ b/DOCKER.md @@ -2,8 +2,10 @@ We provide an easy way to leverage `apktool`, along with common Android tools such as `zipalign` and `apksigner`, all from within Docker. ## Building the Docker image -To build the image, use the included Dockerfile: +To use the image, pull or build with the included Dockerfile: ```bash +docker pull ghcr.io/ibotpeaches/apktool:latest +# OR docker build -t apktool:latest . ``` From e5f60ea1905f51d8792ce8907616935512720975 Mon Sep 17 00:00:00 2001 From: Fmstrat Date: Mon, 2 Oct 2023 12:07:34 +0000 Subject: [PATCH 2/6] updated instructions --- DOCKER.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/DOCKER.md b/DOCKER.md index f162df27b1..4060c8ac62 100644 --- a/DOCKER.md +++ b/DOCKER.md @@ -6,15 +6,15 @@ To use the image, pull or build with the included Dockerfile: ```bash docker pull ghcr.io/ibotpeaches/apktool:latest # OR -docker build -t apktool:latest . +docker build -t apktool:local . ``` ## Using the Docker image -The best way to use the image is to create aliases to run the internal commands: +The best way to use the image is to create aliases to run the internal commands. Replace `ghcr.io/ibotpeaches/apktool:latest` with `apktool:local` if you have built the image locally. ```bash -alias apktool="docker run --rm -ti --name=apktool -v \"${PWD}:${PWD}\" -w \"${PWD}\" apktool:latest apktool" -alias zipalign="docker run --rm -ti --name=zipalign -v \"${PWD}:${PWD}\" -w \"${PWD}\" apktool:latest zipalign" -alias apksigner="docker run --rm -ti --name=apksigner -v \"${PWD}:${PWD}\" -w \"${PWD}\" apktool:latest apksigner" +alias apktool="docker run --rm -ti --name=apktool -v \"${PWD}:${PWD}\" -w \"${PWD}\" ghcr.io/ibotpeaches/apktool:latest apktool" +alias zipalign="docker run --rm -ti --name=zipalign -v \"${PWD}:${PWD}\" -w \"${PWD}\" ghcr.io/ibotpeaches/apktool:latest zipalign" +alias apksigner="docker run --rm -ti --name=apksigner -v \"${PWD}:${PWD}\" -w \"${PWD}\" ghcr.io/ibotpeaches/apktool:latest apksigner" ``` ## Running the commands From 83791c54a9f9ba79a7c6bc7c10eec0746d2b61cd Mon Sep 17 00:00:00 2001 From: Fmstrat Date: Mon, 2 Oct 2023 15:40:59 +0000 Subject: [PATCH 3/6] add tag image --- .github/workflows/docker.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d2cd5d29d9..1c1547e4c6 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -26,16 +26,19 @@ jobs: packages: write steps: - name: Check out the repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Log in to the Container registry uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Get Hash + - name: Get hash id: hash run: echo "GITHUB_HASH=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV + - name: Get release tag + id: tag + run: echo "GITHUB_TAG=$(echo ${GITHUB_REF:-no-tag})" >> $GITHUB_ENV - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx @@ -47,4 +50,4 @@ jobs: platforms: linux/arm64/v8 file: ./docker/dockerfiles/seed.Dockerfile push: true - tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.GITHUB_HASH }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.GITHUB_HASH }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.GITHUB_TAG }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest From eadaf3d10f775a19c804e42217b0659dcecaaf80 Mon Sep 17 00:00:00 2001 From: Fmstrat Date: Mon, 2 Oct 2023 15:44:54 +0000 Subject: [PATCH 4/6] clear refs/tags --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1c1547e4c6..a0dcf18619 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -38,7 +38,7 @@ jobs: run: echo "GITHUB_HASH=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV - name: Get release tag id: tag - run: echo "GITHUB_TAG=$(echo ${GITHUB_REF:-no-tag})" >> $GITHUB_ENV + run: echo "GITHUB_TAG=$(echo ${GITHUB_REF:-no-tag} |sed 's|refs/tags/||g')" >> $GITHUB_ENV - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx From 97d3642a5c05515e74c6584e1970f663ed3929d9 Mon Sep 17 00:00:00 2001 From: Fmstrat Date: Tue, 3 Oct 2023 00:28:01 +0000 Subject: [PATCH 5/6] dockerfile updates --- .github/workflows/docker.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a0dcf18619..a6a370ec86 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -47,7 +47,10 @@ jobs: uses: docker/build-push-action@v4 with: context: . - platforms: linux/arm64/v8 - file: ./docker/dockerfiles/seed.Dockerfile + platforms: linux/amd64 + file: ./Dockerfile push: true - tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.GITHUB_HASH }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.GITHUB_TAG }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + tags: | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.GITHUB_HASH }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.GITHUB_TAG }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest From 91f392a4756f657a77d17aed0a9fca6118dc1080 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Tue, 3 Oct 2023 06:15:11 -0400 Subject: [PATCH 6/6] build: adjust workflow to remove qemu and collision on github_* --- .github/workflows/docker.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a6a370ec86..5474ab802f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -25,8 +25,7 @@ jobs: contents: read packages: write steps: - - name: Check out the repo - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - name: Log in to the Container registry uses: docker/login-action@v2 with: @@ -35,12 +34,10 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Get hash id: hash - run: echo "GITHUB_HASH=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV + run: echo "APKTOOL_HASH=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV - name: Get release tag id: tag - run: echo "GITHUB_TAG=$(echo ${GITHUB_REF:-no-tag} |sed 's|refs/tags/||g')" >> $GITHUB_ENV - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + run: echo "APKTOOL_TAG=$(echo ${GITHUB_REF:-no-tag} |sed 's|refs/tags/||g')" >> $GITHUB_ENV - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Build and push Docker image @@ -51,6 +48,6 @@ jobs: file: ./Dockerfile push: true tags: | - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.GITHUB_HASH }} - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.GITHUB_TAG }} - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.APKTOOL_HASH }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.APKTOOL_TAG }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest