From 57b0d1664bf8912c92035d5038fbc4240fe4c109 Mon Sep 17 00:00:00 2001 From: Paul <22284856+ProgramComputer@users.noreply.github.com> Date: Wed, 3 Jan 2024 13:31:55 -0600 Subject: [PATCH 1/2] Build images for multiple platforms (#169), add build to release * Multi-image docker * Update docker-image.yml * Future php platforms * Change permissions --------- Co-authored-by: HugoFara --- .github/workflows/docker-image.yml | 71 ++++++++++++++++++++++++++++-- Dockerfile | 4 +- 2 files changed, 70 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 58d8b5169..6a20367ef 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,6 +1,8 @@ name: Docker image on: + release: + types: [published] push: branches: [ 'master' ] tags: @@ -11,16 +13,76 @@ env: IMAGE_NAME: ${{ github.repository }} jobs: - build-and-push-image: + build-and-upload-image-to-release: + permissions: write-all runs-on: ubuntu-latest - permissions: - contents: read + strategy: + fail-fast: false + matrix: + platform: #change platform here and below if changed + - linux/amd64 + - linux/386 + - linux/arm/v5 + - linux/arm/v7 + - linux/arm64 + - linux/mips64le + - linux/ppc64le + - linux/s390x + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build Docker images + uses: docker/build-push-action@v3 + with: + context: . + platforms: ${{ matrix.platform }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + outputs: type=oci,dest=/tmp/image.tar + if: ${{ github.event_name == 'release'}} + - name: Upload binaries to release + if: ${{ github.event_name == 'release'}} + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{secrets.GITHUB_TOKEN }} + file: /tmp/image.tar + asset_name: ${{ github.ref_name }}-${{ matrix.platform }} + tag: ${{ github.ref }} + build-and-push-image: + permissions: packages: write + runs-on: ubuntu-latest + strategy: + fail-fast: false steps: + - name: Checkout repository uses: actions/checkout@v3 - + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Log in to the Container registry uses: docker/login-action@v2 with: @@ -39,5 +101,6 @@ jobs: with: context: . push: true + platforms: linux/amd64,linux/386,linux/arm/v5,linux/arm/v7,linux/arm64,linux/mips64le,linux/ppc64le,linux/s390x tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index b7d159409..d1f6aff3d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,4 +16,6 @@ ARG DB_HOSTNAME=db ARG DB_USER=root ARG DB_PASSWORD=root ARG DB_DATABASE=learning-with-texts -RUN printf '' "$DB_HOSTNAME" "$DB_USER" "$DB_PASSWORD" "$DB_DATABASE" > /var/www/html/lwt/connect.inc.php \ No newline at end of file + +RUN printf '' "$DB_HOSTNAME" "$DB_USER" "$DB_PASSWORD" "$DB_DATABASE" > /var/www/html/lwt/connect.inc.php + From 3b4c90b36318f4782f25939a579e1b4ae0a21ffd Mon Sep 17 00:00:00 2001 From: HugoFara Date: Wed, 3 Jan 2024 20:40:30 +0100 Subject: [PATCH 2/2] Documents PR #169, and #141. --- .github/workflows/docker-image.yml | 20 ++++++++++++-------- docs/CHANGELOG.md | 4 ++++ docs/info.html | 3 +++ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 6a20367ef..3955726d7 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -2,7 +2,7 @@ name: Docker image on: release: - types: [published] + types: [ published ] push: branches: [ 'master' ] tags: @@ -14,12 +14,16 @@ env: jobs: build-and-upload-image-to-release: - permissions: write-all + permissions: + contents: write + packages: write + release: write runs-on: ubuntu-latest strategy: fail-fast: false matrix: - platform: #change platform here and below if changed + # For platform support change, change here and below + platform: - linux/amd64 - linux/386 - linux/arm/v5 @@ -31,12 +35,12 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 - + - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - + - name: Log in to the Container registry uses: docker/login-action@v2 with: @@ -67,7 +71,7 @@ jobs: asset_name: ${{ github.ref_name }}-${{ matrix.platform }} tag: ${{ github.ref }} build-and-push-image: - permissions: + permissions: packages: write runs-on: ubuntu-latest strategy: @@ -77,12 +81,12 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - + - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - + - name: Log in to the Container registry uses: docker/login-action@v2 with: diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index b20c9e50f..1d9723f70 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -33,6 +33,10 @@ ones are marked like "v1.0.0-fork". `db/schema/baseline.sql` and no longer in PHP code. * You can choose to add romanization for languages that don't need it in the language settings ([#119](https://github.com/HugoFara/lwt/issues/119)). +* Docker images are now built for multiple platforms, see PR +[#169](https://github.com/HugoFara/lwt/pull/169), closing discussion +[#141](https://github.com/HugoFara/lwt/discussions/141). +Many thanks to [@ProgramComputer](https://github.com/ProgramComputer)! ### Changed diff --git a/docs/info.html b/docs/info.html index 011ac4059..875de7a32 100644 --- a/docs/info.html +++ b/docs/info.html @@ -2254,6 +2254,9 @@

Added

db/schema/baseline.sql and no longer in PHP code.
  • You can choose to add romanization for languages that don't need it in the language settings (#119).
  • +
  • Docker images are now built for multiple platforms, see +#159. +Many thanks to @ProgramComputer!
  • Changed