From 3bd63992b5a163ce4c4a40883f3534786dab3f2d Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Thu, 4 Mar 2021 16:35:23 +0000 Subject: [PATCH] Simplify Docker image Since #5665, we might get away with the PHP 8.0 image variant only, and also no longer need to scope the Rector source code. --- .github/workflows/publish_docker_images.yaml | 21 +++++------------- Dockerfile | 23 ++++++++++---------- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/.github/workflows/publish_docker_images.yaml b/.github/workflows/publish_docker_images.yaml index 8af8f8aaeaa2..d66aa6efdfb0 100644 --- a/.github/workflows/publish_docker_images.yaml +++ b/.github/workflows/publish_docker_images.yaml @@ -12,9 +12,6 @@ on: jobs: publish_images: runs-on: ubuntu-20.04 - strategy: - matrix: - php-version: ['7.3', '7.4', '8.0'] steps: - name: Checkout uses: actions/checkout@v2 @@ -37,17 +34,11 @@ jobs: BRANCH=$(echo "${{ github.ref }}" | sed -e '/refs\/heads\//!d; s,refs/.*/\(.*\),\1,') if [ "master" == "$BRANCH" ]; then - DOCKER_TAGS="$DOCKER_TAGS php${{ matrix.php-version }}" - if [ "8.0" == "${{ matrix.php-version }}" ]; then - DOCKER_TAGS="$DOCKER_TAGS latest" - fi + DOCKER_TAGS="$DOCKER_TAGS latest" fi if [ ! -z "$TAG" ]; then - DOCKER_TAGS="$DOCKER_TAGS $TAG-php${{ matrix.php-version }}" - if [ "8.0" == "${{ matrix.php-version }}" ]; then - DOCKER_TAGS="$DOCKER_TAGS $TAG" - fi + DOCKER_TAGS="$DOCKER_TAGS $TAG" fi echo "Image will be tagged with: $DOCKER_TAGS" @@ -57,13 +48,13 @@ jobs: DOCKER_TAG_ARG="$DOCKER_TAG_ARG --tag rector/rector:$ARG" done - docker buildx create --name builder-php${{ matrix.php-version }} --use + docker buildx create --name builder --use docker buildx build \ --progress plain \ - --cache-from=rector/rector:build-cache-php${{ matrix.php-version }} \ - --cache-to=type=registry,ref=rector/rector:build-cache-php${{ matrix.php-version }},mode=max,push=true \ + --cache-from=rector/rector:build-cache \ + --cache-to=type=registry,ref=rector/rector:build-cache,mode=max,push=true \ --target rector \ --push \ $DOCKER_TAG_ARG \ --platform linux/amd64,linux/arm64 \ - --build-arg PHP_VERSION=${{ matrix.php-version }} . + --build-arg . diff --git a/Dockerfile b/Dockerfile index 3aa3609791fe..c51c1f3447a9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,23 +31,22 @@ RUN apt-get update && apt-get install -y \ COPY --from=composer:2.0.9 /usr/bin/composer /usr/bin/composer ENV COMPOSER_ALLOW_SUPERUSER=1 COMPOSER_MEMORY_LIMIT=-1 COMPOSER_NO_INTERACTION=1 -# Run php-scoper, results go to /scoped -RUN wget /~https://github.com/humbug/php-scoper/releases/download/0.14.0/php-scoper.phar -N --no-verbose - -# This is to make parsing version possible -COPY .git .git - # First copy composer.json only to leverage the build cache (as long as not git-committing) COPY composer.json composer.json RUN composer install --no-dev --no-progress --no-autoloader --prefer-dist -# Add source and generate full autoloader -COPY . . +# Copy relevant source paths +COPY bin bin +COPY config config +COPY packages packages +COPY rules rules +COPY src src +COPY templates templates RUN composer dump-autoload --optimize --classmap-authoritative --no-dev -RUN rm -f "phpstan-for-rector.neon" \ - && php -d memory_limit=-1 php-scoper.phar add-prefix bin config packages rules src templates vendor composer.json --output-dir /scoped --config scoper.php \ - && composer dump-autoload --optimize --classmap-authoritative --no-dev --working-dir /scoped +# Parse versions +COPY .git .git +RUN composer install --no-dev --no-progress --no-autoloader --prefer-dist && rm -rf .git # Build runtime image FROM base as rector @@ -63,7 +62,7 @@ ENTRYPOINT [ "rector" ] VOLUME ["/project"] WORKDIR "/project" -COPY --from=build /scoped /rector +COPY --from=build /build /rector RUN chmod +x /rector/bin/rector RUN mkdir -p /tmp/opcache \