Skip to content

Commit

Permalink
add docker image building
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Jan 20, 2024
1 parent f0f7ee4 commit 52e1fbf
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build Docker Image

on:
push:
paths:
- build.sh
- .github/workflows/build.yml
workflow_dispatch:

permissions:
contents: read
packages: write

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- arch: amd64
- arch: arm64
steps:
- name: Clone
uses: actions/checkout@v4

- name: Install Chisel
uses: shyim/chisel-installer@main

- name: Build image
run: ./build.sh ${{ matrix.arch }} --push
merge:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Login into Github Docker Registery
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- run: docker manifest create friendsofshopware/code-style:latest --amend friendsofshopware/code-style-amd64 --amend friendsofshopware/code-style-arm64

- run: docker manifest push friendsofshopware/code-style:latest
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
vendor
.php-cs-fixer.cache
/db
/rootfs
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM --platform=$BUILDPLATFORM composer as download

ADD . /cs-fix
WORKDIR /cs-fix
RUN composer install --no-dev --no-interaction --no-progress --no-suggest --optimize-autoloader
RUN echo 'memory_limit = -1' > /php.ini

FROM scratch

LABEL org.opencontainers.image.authors="FriendsOfShopware" \
org.opencontainers.image.url="https://github.com/FriendsOfShopware/code-style" \
org.opencontainers.image.source="https://github.com/FriendsOfShopware/code-style" \
org.opencontainers.image.vendor="FriendsOfShopware" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.title="PHP-CS-Fixer"
COPY rootfs/ /

COPY --from=download /cs-fix /cs-fix
COPY --from=download /php.ini /etc/php/8.2/cli/conf.d/99-memory-limit.ini
ENTRYPOINT ["/usr/bin/php", "/cs-fix/bin/frosh-cs", "fix"]
28 changes: 28 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

set -eo pipefail

arch=$1
params=$2

if [ -z "$arch" ]; then
echo "Usage: $0 <arch>"
exit 1
fi

echo "Building version $version"

rm -rf rootfs
mkdir rootfs

if [[ ! -d db ]]; then
git clone -b ubuntu-23.10-php https://github.com/shyim/chisel-releases.git db
fi

chisel cut --arch=$arch --release ./db --root rootfs/ php8.2-cli_base php8.2-common_all-cli php8.2-common_phar-cli php8.2-mbstring_cli php8.2-xml_dom-cli dash_bins

docker build --platform "linux/${arch}" -t "friendsofshopware/code-style:${version}-${arch}" .

if [[ "$params" == "--push" ]]; then
docker push "friendsofshopware/code-style:${version}-${arch}"
fi

0 comments on commit 52e1fbf

Please sign in to comment.