laravel / sail

Docker files for running a basic Laravel application.
https://laravel.com/docs/sail
MIT License
1.68k stars 476 forks source link

Automatically publish releases to Docker Hub? #194

Closed stevegrunwell closed 3 years ago

stevegrunwell commented 3 years ago

Description:

I'm attempting to use the Laravel Sail Docker image in a GitLab CI/CD environment, but am running into the following error:

> php-cs-fixer fix -v --diff --dry-run PHP needs to be a minimum version of PHP 7.1.3 and maximum version of PHP 8.0.*. Current PHP version: 8.0.0. PHP CS Fixer is not able run on PHP 8.0.0 due to bug in PHP tokenizer (https://bugs.php.net/bug.php?id=80462). Update PHP version to unblock execution. Script php-cs-fixer fix -v --diff --dry-run handling the test:standards event returned with error code 1

It appears that the laravelsail/php80-composer:latest image on Docker Hub hasn't been pushed in 7 months and, at the time that it was last built, it was using PHP 8.0.0 (thus causing the php-cs-fixer issue noted above).

Within the image layers, one layer explicitly defines PHP version 8.0.0:

ENV PHP_VERSION=8.0.0

Relevant snippets from my .gitlab-ci.yml file, for reference:

image: laravelsail/php80-composer:latest

Install Composer dependencies:
    stage: build
    tags:
        - docker
    script:
        - composer install --prefer-dist --no-ansi --no-interaction --no-progress
    artifacts:
        paths:
            - .env
            - vendor
    cache:
        key: ${CI_COMMIT_REF_SLUG}-composer
        paths:
            - vendor

Check coding standards:
    stage: test
    tags:
        - docker
    script:
        - composer test:standards
    cache:
        key: ${CI_COMMIT_REF_SLUG}-php-cs-fixer
        paths:
            - .php-cs-fixer.cache

Proposed solution:

Would it be possible to set up a GitHub action (or similar) to automatically push new releases to Docker Hub, please? That would ensure that laravelsail/php80-composer:latest actually corresponds to the latest release.

This may be configurable from within Docker Hub itself (without external pipeline tools), but only by a member of the "laravelsail" organization:

Thank you!

driesvints commented 3 years ago

That container isn't used in Sail. Sail is composed from a Docker file.

stevegrunwell commented 3 years ago

Understood, though this does appear to be the source of that Docker Hub image, is it not? With over 100k pulls on that image, it seems it would be helpful to the community if there was an "official" PHP-based container to use in CI/CD pipelines — especially if its pushes are tied to tagged releases in this repository.

Is there an alternative Docker image recommended by the core Laravel team for continuous integration purposes?

saulens22 commented 3 years ago

I suggest doing it yourself like this: https://github.com/saulens22/php80-composer

You will have full control over what's in the image.

driesvints commented 3 years ago

Hey @stevegrunwell, I'm sorry I was a bit incorrect there. Sail indeed doesn't uses the image from above directly. The image in fact is used only when to set up new Laravel projects when running the curl command from the installation docs.

At the moment we indeed don't have an image for CI/CD purposes and we're not actively planning for one, sorry. If you need one it's best to either create one yourself or set up your CI/CD environment with a different one.

stevegrunwell commented 3 years ago

@driesvints Thank you for the clarification. I suppose I'll stick with the lorisleiva/laravel-docker image for now.