Skip to content

Commit

Permalink
Build images for multiple platforms (#169), add build to release
Browse files Browse the repository at this point in the history
* Multi-image docker
* Update docker-image.yml
* Future php platforms
* Change permissions

---------

Co-authored-by: HugoFara <[email protected]>
  • Loading branch information
ProgramComputer and HugoFara authored Jan 3, 2024
1 parent e31d838 commit 57b0d16
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 5 deletions.
71 changes: 67 additions & 4 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Docker image

on:
release:
types: [published]
push:
branches: [ 'master' ]
tags:
Expand All @@ -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:
Expand All @@ -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 }}
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ ARG DB_HOSTNAME=db
ARG DB_USER=root
ARG DB_PASSWORD=root
ARG DB_DATABASE=learning-with-texts
RUN printf '<?php\n$server = "%s";\n$userid = "%s";\n$passwd = "%s";\n$dbname = "%s";\n?>' "$DB_HOSTNAME" "$DB_USER" "$DB_PASSWORD" "$DB_DATABASE" > /var/www/html/lwt/connect.inc.php

RUN printf '<?php\n$server = "%s";\n$userid = "%s";\n$passwd = "%s";\n$dbname = "%s";\n?>' "$DB_HOSTNAME" "$DB_USER" "$DB_PASSWORD" "$DB_DATABASE" > /var/www/html/lwt/connect.inc.php

0 comments on commit 57b0d16

Please sign in to comment.