diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e010612..b0d8cdd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,6 +8,7 @@ on: push: branches: - main + pull_request: schedule: - cron: 43 2 * * 0 @@ -25,17 +26,6 @@ jobs: runs-on: ubuntu-latest steps: - - - uses: docker/setup-qemu-action@v2 - - - uses: actions/checkout@v4 - - - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Determine Psalm version to build run: | if [[ -z "$PSALM_VERSION" ]]; then @@ -53,39 +43,49 @@ jobs: env: PSALM_VERSION: ${{ github.event.inputs.psalmVersion }} - - name: Build Docker Image - run: | - docker buildx create --name builder --use - docker buildx build \ - --progress plain \ - --platform=linux/amd64,linux/arm64 \ - --cache-from=ghcr.io/webfactory/psalm:build-cache \ - --cache-to=type=registry,ref=ghcr.io/webfactory/psalm:build-cache,mode=max,push=true \ - --pull \ - --build-arg PSALM_VERSION="$PSALM_VERSION" \ - . + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and cache multi-platform image + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64,linux/arm64 + build-args: PSALM_VERSION=${{ env.PSALM_VERSION }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Load image for current platform into local Docker + # see https://github.com/docker/buildx/issues/59 for reason/limitation + uses: docker/build-push-action@v6 + with: + build-args: PSALM_VERSION=${{ env.PSALM_VERSION }} + cache-from: type=gha + load: true + tags: build + env: + DOCKER_BUILD_SUMMARY: false + DOCKER_BUILD_RECORD_UPLOAD: false - name: Run smoke tests run: | - # Load image for current platform into local Docker (see https://github.com/docker/buildx/issues/59) - docker buildx build \ - --progress plain \ - --cache-from=ghcr.io/webfactory/psalm:build-cache \ - --tag build \ - --build-arg PSALM_VERSION="$PSALM_VERSION" \ - --load . - # Check "psalm --version" output docker run --rm build --version | grep -q $PSALM_VERSION - name: Push image to registry if: github.event_name != 'pull_request' - run: | - docker buildx build \ - --progress plain \ - --platform=linux/amd64,linux/arm64 \ - --cache-from=ghcr.io/webfactory/psalm:build-cache \ - --tag ghcr.io/webfactory/psalm:"$PSALM_VERSION" \ - --label org.opencontainers.image.source=https://github.com/webfactory/docker-psalm \ - --build-arg PSALM_VERSION="$PSALM_VERSION" \ - --push . + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64,linux/arm64 + build-args: PSALM_VERSION=${{ env.PSALM_VERSION }} + cache-from: type=gha + push: true + tags: ghcr.io/webfactory/psalm:${{ env.PSALM_VERSION }} + labels: org.opencontainers.image.source=https://github.com/webfactory/docker-psalm + env: + DOCKER_BUILD_SUMMARY: false + DOCKER_BUILD_RECORD_UPLOAD: false diff --git a/Dockerfile b/Dockerfile index f8dc21e..9f88d85 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,14 @@ -FROM php:8-cli-alpine as build-extensions +FROM php:8-cli-alpine AS build-extensions RUN docker-php-ext-install pcntl posix RUN apk add icu-dev RUN docker-php-ext-configure intl && docker-php-ext-install intl -FROM composer:2 as composer-fetch +FROM composer:2 AS composer-fetch ARG PSALM_VERSION=* ENV COMPOSER_ALLOW_SUPERUSER=1 COMPOSER_MEMORY_LIMIT=-1 COMPOSER_NO_INTERACTION=1 COMPOSER_HOME="/composer" RUN composer global require "vimeo/psalm:$PSALM_VERSION" "psalm/plugin-symfony:*" "psalm/plugin-phpunit:*" "weirdan/doctrine-psalm-plugin:*" -FROM php:8-cli-alpine as runtime +FROM php:8-cli-alpine AS runtime RUN apk add icu COPY --from=build-extensions /usr/local/lib/php /usr/local/lib/php @@ -26,7 +26,7 @@ RUN chmod +x /entrypoint.sh # Package container -ENV XDG_CACHE_HOME /cache +ENV XDG_CACHE_HOME=/cache VOLUME ["/cache"] WORKDIR "/app"