From e1d5ae8f30cc30fa68dbc32fd7e0f7d0a88ab1d2 Mon Sep 17 00:00:00 2001 From: Henning Bocklage Date: Mon, 20 Sep 2021 21:30:50 +0200 Subject: [PATCH 1/5] New docker build mechanism --- .github/workflows/dockerbuild-latest.yml | 46 +++++++++++++++++++++ .github/workflows/dockerbuild-release.yml | 50 +++++++++++++++++++++++ Dockerfile | 17 +------- docker-bake.hcl | 23 +++++++++++ 4 files changed, 120 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/dockerbuild-latest.yml create mode 100644 .github/workflows/dockerbuild-release.yml create mode 100644 docker-bake.hcl diff --git a/.github/workflows/dockerbuild-latest.yml b/.github/workflows/dockerbuild-latest.yml new file mode 100644 index 00000000000..24d8c12d59e --- /dev/null +++ b/.github/workflows/dockerbuild-latest.yml @@ -0,0 +1,46 @@ +name: Build Image On Commit + +on: + push: + branches: [ master ] + +env: + DOCKERHUB_SLUG: rssbridge/rss-bridge + +jobs: + bake: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2.3.4 + - + name: Docker meta + id: docker_meta + uses: docker/metadata-action@v3.3.0 + with: + images: | + ${{ env.DOCKERHUB_SLUG }} + tags: | + type=raw,value=latest + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1.3.0 + - + name: Login to DockerHub + uses: docker/login-action@v1.9.0 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - + name: Build and push + uses: docker/bake-action@v1.4.2 + with: + files: | + ./docker-bake.hcl + ${{ steps.docker_meta.outputs.bake-file }} + targets: image-all + push: true \ No newline at end of file diff --git a/.github/workflows/dockerbuild-release.yml b/.github/workflows/dockerbuild-release.yml new file mode 100644 index 00000000000..3b6b5115e4a --- /dev/null +++ b/.github/workflows/dockerbuild-release.yml @@ -0,0 +1,50 @@ +name: Build Image On Release + +on: + push: + tags: + - '20*' + +env: + DOCKERHUB_SLUG: rssbridge/rss-bridge + +jobs: + bake: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2.3.4 + - + name: Docker meta + id: docker_meta + uses: docker/metadata-action@v3.3.0 + with: + images: | + ${{ env.DOCKERHUB_SLUG }} + tags: | + type=ref,event=tag + type=raw,value=stable + flavor: | + latest=false + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1.3.0 + - + name: Login to DockerHub + uses: docker/login-action@v1.9.0 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - + name: Build and push + uses: docker/bake-action@v1.4.2 + with: + files: | + ./docker-bake.hcl + ${{ steps.docker_meta.outputs.bake-file }} + targets: image-all + push: true \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 7e87b04d13f..88be787e781 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,9 @@ -ARG FROM_ARCH=amd64 - -# Multi-stage build, see https://docs.docker.com/develop/develop-images/multistage-build/ -FROM alpine AS builder - -# Download QEMU -ADD https://github.com/balena-io/qemu/releases/download/v5.2.0%2Bbalena4/qemu-5.2.0.balena4-arm.tar.gz . -RUN tar zxvf qemu-5.2.0.balena4-arm.tar.gz --strip-components 1 -ADD https://github.com/balena-io/qemu/releases/download/v5.2.0%2Bbalena4/qemu-5.2.0.balena4-aarch64.tar.gz . -RUN tar zxvf qemu-5.2.0.balena4-aarch64.tar.gz --strip-components 1 - -FROM $FROM_ARCH/php:7-apache +FROM php:7-apache LABEL description="RSS-Bridge is a PHP project capable of generating RSS and Atom feeds for websites that don't have one." LABEL repository="https://github.com/RSS-Bridge/rss-bridge" LABEL website="https://github.com/RSS-Bridge/rss-bridge" -# Add QEMU -COPY --from=builder qemu-arm-static /usr/bin -COPY --from=builder qemu-aarch64-static /usr/bin - ENV APACHE_DOCUMENT_ROOT=/app RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \ diff --git a/docker-bake.hcl b/docker-bake.hcl new file mode 100644 index 00000000000..5b9e8113aae --- /dev/null +++ b/docker-bake.hcl @@ -0,0 +1,23 @@ +target "docker-metadata-action" {} + +group "default" { + targets = ["image-local"] +} + +target "image" { + inherits = ["docker-metadata-action"] +} + +target "image-local" { + inherits = ["image"] + output = ["type=docker"] +} + +target "image-all" { + inherits = ["image"] + platforms = [ + "linux/amd64", + "linux/arm64", + "linux/arm/v7" + ] +} From 71f621b62fd09be8c7133afec6c0b18fe8e4f146 Mon Sep 17 00:00:00 2001 From: Henning Bocklage Date: Mon, 20 Sep 2021 21:36:55 +0200 Subject: [PATCH 2/5] Remove old hooks for dockerhub. --- hooks/build | 10 ---------- hooks/post_push | 34 ---------------------------------- hooks/pre_build | 5 ----- hooks/push | 9 --------- 4 files changed, 58 deletions(-) delete mode 100644 hooks/build delete mode 100644 hooks/post_push delete mode 100644 hooks/pre_build delete mode 100644 hooks/push diff --git a/hooks/build b/hooks/build deleted file mode 100644 index 4d9e99abdc7..00000000000 --- a/hooks/build +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -# Custom build script to build images for all supported architectures. -# Example for IMAGE_NAME: rss-builder/rss-builder:stable - -for arch in amd64 arm32v7 arm64v8 -do - echo "Building $IMAGE_NAME-$arch" - docker build --build-arg FROM_ARCH=$arch --file $DOCKERFILE_PATH --tag $IMAGE_NAME-$arch . -done diff --git a/hooks/post_push b/hooks/post_push deleted file mode 100644 index 45db96dfe45..00000000000 --- a/hooks/post_push +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -# Use manifest-tool to create the manifest, given the experimental -# "docker manifest" command isn't available yet on Docker Hub. -MANIFEST_TOOL_VERSION=$(curl -s https://api.github.com/repos/estesp/manifest-tool/releases/latest | grep 'tag_name' | cut -d\" -f4) -curl -Lo manifest-tool https://github.com/estesp/manifest-tool/releases/download/$MANIFEST_TOOL_VERSION/manifest-tool-linux-amd64 -chmod +x manifest-tool - -# Generate the manifest file. -# Parameter 1 is the multi-arch image name, e.g. rss-bridge/rss-bridge:stable -function generate_manifest { - cat > manifest-generated.yaml << EOF -image: $1 -manifests: - - image: $1-amd64 - platform: - architecture: amd64 - os: linux - - image: $1-arm32v7 - platform: - architecture: arm - os: linux - variant: v7 - - image: $1-arm64v8 - platform: - architecture: arm64 - os: linux - variant: v8 -EOF -} - -echo "Pushing multi-arch manifest $IMAGE_NAME" -generate_manifest $IMAGE_NAME -./manifest-tool push from-spec manifest-generated.yaml diff --git a/hooks/pre_build b/hooks/pre_build deleted file mode 100644 index 76a62755c7f..00000000000 --- a/hooks/pre_build +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -# Register qemu-*-static for all supported processors except the -# current one, but also remove all registered binfmt_misc before -docker run --rm --privileged multiarch/qemu-user-static:register --reset \ No newline at end of file diff --git a/hooks/push b/hooks/push deleted file mode 100644 index 297ddd050a9..00000000000 --- a/hooks/push +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -# Custom build script to push images for all supported architectures. - -for arch in amd64 arm32v7 arm64v8 -do - echo "Pushing $IMAGE_NAME-$arch" - docker push $IMAGE_NAME-$arch -done From 920c271e629a1b2b6a1586bd5e9204cc7abd4bc9 Mon Sep 17 00:00:00 2001 From: Henning Bocklage Date: Mon, 27 Sep 2021 19:56:26 +0200 Subject: [PATCH 3/5] test single file --- .github/workflows/dockerbuild-latest.yml | 46 ------------------- ...ockerbuild-release.yml => dockerbuild.yml} | 22 ++++----- 2 files changed, 11 insertions(+), 57 deletions(-) delete mode 100644 .github/workflows/dockerbuild-latest.yml rename .github/workflows/{dockerbuild-release.yml => dockerbuild.yml} (61%) diff --git a/.github/workflows/dockerbuild-latest.yml b/.github/workflows/dockerbuild-latest.yml deleted file mode 100644 index 24d8c12d59e..00000000000 --- a/.github/workflows/dockerbuild-latest.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Build Image On Commit - -on: - push: - branches: [ master ] - -env: - DOCKERHUB_SLUG: rssbridge/rss-bridge - -jobs: - bake: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v2.3.4 - - - name: Docker meta - id: docker_meta - uses: docker/metadata-action@v3.3.0 - with: - images: | - ${{ env.DOCKERHUB_SLUG }} - tags: | - type=raw,value=latest - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1.3.0 - - - name: Login to DockerHub - uses: docker/login-action@v1.9.0 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Build and push - uses: docker/bake-action@v1.4.2 - with: - files: | - ./docker-bake.hcl - ${{ steps.docker_meta.outputs.bake-file }} - targets: image-all - push: true \ No newline at end of file diff --git a/.github/workflows/dockerbuild-release.yml b/.github/workflows/dockerbuild.yml similarity index 61% rename from .github/workflows/dockerbuild-release.yml rename to .github/workflows/dockerbuild.yml index 3b6b5115e4a..68259bb9ea6 100644 --- a/.github/workflows/dockerbuild-release.yml +++ b/.github/workflows/dockerbuild.yml @@ -1,12 +1,14 @@ -name: Build Image On Release +name: Build Image on Commit and Release on: push: + branches: + - 'main' tags: - '20*' env: - DOCKERHUB_SLUG: rssbridge/rss-bridge + DOCKERHUB_SLUG: bocki/rss-bridge-test jobs: bake: @@ -18,33 +20,31 @@ jobs: - name: Docker meta id: docker_meta - uses: docker/metadata-action@v3.3.0 + uses: docker/metadata-action@v3.5.0 with: images: | ${{ env.DOCKERHUB_SLUG }} tags: | - type=ref,event=tag - type=raw,value=stable - flavor: | - latest=false + type=ref,event=tag,enable=${{ !startsWith(github.ref, 'refs/tags/20') }} + type=raw,value=stable,enable=${{ !startsWith(github.ref, 'refs/tags/20') }} - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1.3.0 + uses: docker/setup-buildx-action@v1.6.0 - name: Login to DockerHub - uses: docker/login-action@v1.9.0 + uses: docker/login-action@v1.10.0 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and push - uses: docker/bake-action@v1.4.2 + uses: docker/bake-action@v1.6.0 with: files: | ./docker-bake.hcl ${{ steps.docker_meta.outputs.bake-file }} targets: image-all - push: true \ No newline at end of file + push: true From b55b867c5274081ad8bb7011ce6e5c93b07f5ee9 Mon Sep 17 00:00:00 2001 From: Henning Bocklage Date: Mon, 27 Sep 2021 20:21:42 +0200 Subject: [PATCH 4/5] Final working version. --- .github/workflows/dockerbuild.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dockerbuild.yml b/.github/workflows/dockerbuild.yml index 68259bb9ea6..abc52756270 100644 --- a/.github/workflows/dockerbuild.yml +++ b/.github/workflows/dockerbuild.yml @@ -3,12 +3,13 @@ name: Build Image on Commit and Release on: push: branches: - - 'main' + - 'master' tags: - '20*' env: - DOCKERHUB_SLUG: bocki/rss-bridge-test + DOCKERHUB_SLUG: rssbridge/rss-bridge + GHCR_SLUG: ghcr.io/rss-bridge/rss-bridge jobs: bake: @@ -24,9 +25,11 @@ jobs: with: images: | ${{ env.DOCKERHUB_SLUG }} + ${{ env.GHCR_SLUG }} tags: | - type=ref,event=tag,enable=${{ !startsWith(github.ref, 'refs/tags/20') }} - type=raw,value=stable,enable=${{ !startsWith(github.ref, 'refs/tags/20') }} + type=raw,value=latest + type=ref,event=tag,enable=${{ startsWith(github.ref, 'refs/tags/20') }} + type=raw,value=stable,enable=${{ startsWith(github.ref, 'refs/tags/20') }} - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -39,6 +42,13 @@ jobs: with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + - + name: Login to GitHub Container Registry + uses: docker/login-action@v1.10.0 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GHCR_PAT }} - name: Build and push uses: docker/bake-action@v1.6.0 From 5b377162664b461f5b6e9c478cd8d56491d1d9b4 Mon Sep 17 00:00:00 2001 From: Henning Bocklage Date: Mon, 27 Sep 2021 20:28:20 +0200 Subject: [PATCH 5/5] Changed github login --- .github/workflows/dockerbuild.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dockerbuild.yml b/.github/workflows/dockerbuild.yml index abc52756270..753961909cc 100644 --- a/.github/workflows/dockerbuild.yml +++ b/.github/workflows/dockerbuild.yml @@ -47,8 +47,8 @@ jobs: uses: docker/login-action@v1.10.0 with: registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GHCR_PAT }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push uses: docker/bake-action@v1.6.0