From 558eddfb90ef8da0fdcc29f663d85f21437f1b16 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 16 Feb 2024 20:48:49 +0100 Subject: [PATCH 01/31] adapt for laravel --- .editorconfig | 52 +++---------------- .gitattributes | 22 +++----- Dockerfile | 15 +++--- README.md | 89 ++++++++++++++++++++------------- compose.override.yaml | 4 -- compose.yaml | 16 +----- frankenphp/Caddyfile | 32 ------------ frankenphp/docker-entrypoint.sh | 47 ++--------------- frankenphp/worker.Caddyfile | 4 -- 9 files changed, 78 insertions(+), 203 deletions(-) delete mode 100644 frankenphp/worker.Caddyfile diff --git a/.editorconfig b/.editorconfig index 1ea821469..8f0de65c5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,58 +1,18 @@ -# EditorConfig helps developers define and maintain consistent -# coding styles between different editors and IDEs -# editorconfig.org - root = true [*] -# Change these settings to your own preference -indent_style = space -indent_size = 4 - -# We recommend you to keep these unchanged -end_of_line = lf charset = utf-8 -trim_trailing_whitespace = true +end_of_line = lf +indent_size = 4 +indent_style = space insert_final_newline = true - -[*.{js,html,ts,tsx}] -indent_size = 2 - -[*.json] -indent_size = 2 +trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false -[*.sh] -indent_style = tab - -[*.xml{,.dist}] -indent_style = space -indent_size = 4 - -[*.{yaml,yml}] -trim_trailing_whitespace = false - -[.github/workflows/*.yml] +[*.{yml,yaml}] indent_size = 2 -[.gitmodules] -indent_style = tab - -[.php_cs{,.dist}] -indent_style = space -indent_size = 4 - -[composer.json] +[docker-compose.yml] indent_size = 4 - -[{,docker-}compose{,.*}.{yaml,yml}] -indent_style = space -indent_size = 2 - -[{,*.*}Dockerfile] -indent_style = tab - -[{,*.*}Caddyfile] -indent_style = tab diff --git a/.gitattributes b/.gitattributes index 642c91f2d..fcb21d396 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,17 +1,11 @@ * text=auto eol=lf -*.conf text eol=lf -*.html text eol=lf -*.ini text eol=lf -*.js text eol=lf -*.json text eol=lf -*.md text eol=lf -*.php text eol=lf -*.sh text eol=lf -*.yaml text eol=lf -*.yml text eol=lf -bin/console text eol=lf -composer.lock text eol=lf merge=ours +*.blade.php diff=html +*.css diff=css +*.html diff=html +*.md diff=markdown +*.php diff=php -*.ico binary -*.png binary +/.github export-ignore +CHANGELOG.md export-ignore +.styleci.yml export-ignore diff --git a/Dockerfile b/Dockerfile index c19deb692..9711345a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,7 +50,7 @@ CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile" ] FROM frankenphp_base AS frankenphp_dev ENV APP_ENV=dev XDEBUG_MODE=off -VOLUME /app/var/ +VOLUME /app/storage/ /app/bootstrap/cache/ RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" @@ -67,15 +67,13 @@ CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile", "--watch" ] FROM frankenphp_base AS frankenphp_prod ENV APP_ENV=prod -ENV FRANKENPHP_CONFIG="import worker.Caddyfile" RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" COPY --link frankenphp/conf.d/app.prod.ini $PHP_INI_DIR/conf.d/ -COPY --link frankenphp/worker.Caddyfile /etc/caddy/worker.Caddyfile # prevent the reinstallation of vendors at every changes in the source code -COPY --link composer.* symfony.* ./ +COPY --link composer.* ./ RUN set -eux; \ composer install --no-cache --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress @@ -84,8 +82,7 @@ COPY --link . ./ RUN rm -Rf frankenphp/ RUN set -eux; \ - mkdir -p var/cache var/log; \ - composer dump-autoload --classmap-authoritative --no-dev; \ - composer dump-env prod; \ - composer run-script --no-dev post-install-cmd; \ - chmod +x bin/console; sync; + mkdir -p storage/framework/{sessions,views,cache,testing} storage/logs bootstrap/cache; \ + chmod -R a+rw storage; \ + composer install --classmap-authoritative --no-interaction --no-ansi --no-dev; \ + php artisan storage:link; diff --git a/README.md b/README.md index a48435358..1a4c26ba3 100644 --- a/README.md +++ b/README.md @@ -1,49 +1,66 @@ -# Symfony Docker +

Laravel Logo

-A [Docker](https://www.docker.com/)-based installer and runtime for the [Symfony](https://symfony.com) web framework, -with [FrankenPHP](https://frankenphp.dev) and [Caddy](https://caddyserver.com/) inside! +

+Build Status +Total Downloads +Latest Stable Version +License +

-![CI](https://github.com/dunglas/symfony-docker/workflows/CI/badge.svg) +## About Laravel -## Getting Started +Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: -1. If not already done, [install Docker Compose](https://docs.docker.com/compose/install/) (v2.10+) -2. Run `docker compose build --no-cache` to build fresh images -3. Run `docker compose up --pull always -d --wait` to start the project -4. Open `https://localhost` in your favorite web browser and [accept the auto-generated TLS certificate](https://stackoverflow.com/a/15076602/1352334) -5. Run `docker compose down --remove-orphans` to stop the Docker containers. +- [Simple, fast routing engine](https://laravel.com/docs/routing). +- [Powerful dependency injection container](https://laravel.com/docs/container). +- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. +- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). +- Database agnostic [schema migrations](https://laravel.com/docs/migrations). +- [Robust background job processing](https://laravel.com/docs/queues). +- [Real-time event broadcasting](https://laravel.com/docs/broadcasting). -## Features +Laravel is accessible, powerful, and provides tools required for large, robust applications. -* Production, development and CI ready -* Just 1 service by default -* Blazing-fast performance thanks to [the worker mode of FrankenPHP](https://github.com/dunglas/frankenphp/blob/main/docs/worker.md) (automatically enabled in prod mode) -* [Installation of extra Docker Compose services](docs/extra-services.md) with Symfony Flex -* Automatic HTTPS (in dev and prod) -* HTTP/3 and [Early Hints](https://symfony.com/blog/new-in-symfony-6-3-early-hints) support -* Real-time messaging thanks to a built-in [Mercure hub](https://symfony.com/doc/current/mercure.html) -* [Vulcain](https://vulcain.rocks) support -* Native [XDebug](docs/xdebug.md) integration -* Super-readable configuration +## Learning Laravel -**Enjoy!** +Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. -## Docs +You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch. -1. [Build options](docs/build.md) -2. [Using Symfony Docker with an existing project](docs/existing-project.md) -3. [Support for extra services](docs/extra-services.md) -4. [Deploying in production](docs/production.md) -5. [Debugging with Xdebug](docs/xdebug.md) -6. [TLS Certificates](docs/tls.md) -7. [Using a Makefile](docs/makefile.md) -8. [Troubleshooting](docs/troubleshooting.md) -9. [Updating the template](docs/updating.md) +If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. -## License +## Laravel Sponsors + +We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com). + +### Premium Partners + +- **[Vehikl](https://vehikl.com/)** +- **[Tighten Co.](https://tighten.co)** +- **[WebReinvent](https://webreinvent.com/)** +- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** +- **[64 Robots](https://64robots.com)** +- **[Curotec](https://www.curotec.com/services/technologies/laravel/)** +- **[Cyber-Duck](https://cyber-duck.co.uk)** +- **[DevSquad](https://devsquad.com/hire-laravel-developers)** +- **[Jump24](https://jump24.co.uk)** +- **[Redberry](https://redberry.international/laravel/)** +- **[Active Logic](https://activelogic.com)** +- **[byte5](https://byte5.de)** +- **[OP.GG](https://op.gg)** + +## Contributing -Symfony Docker is available under the MIT License. +Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). -## Credits +## Code of Conduct + +In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). + +## Security Vulnerabilities + +If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. + +## License -Created by [Kévin Dunglas](https://dunglas.dev), co-maintained by [Maxime Helias](https://twitter.com/maxhelias) and sponsored by [Les-Tilleuls.coop](https://les-tilleuls.coop). +The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). diff --git a/compose.override.yaml b/compose.override.yaml index 5f141b1f1..8df70faca 100644 --- a/compose.override.yaml +++ b/compose.override.yaml @@ -12,13 +12,9 @@ services: # from the bind-mount for better performance by enabling the next line: #- /app/vendor environment: - MERCURE_EXTRA_DIRECTIVES: demo # See https://xdebug.org/docs/all_settings#mode XDEBUG_MODE: "${XDEBUG_MODE:-off}" extra_hosts: # Ensure that host.docker.internal is correctly defined on Linux - host.docker.internal:host-gateway tty: true - -###> symfony/mercure-bundle ### -###< symfony/mercure-bundle ### diff --git a/compose.yaml b/compose.yaml index 43a079003..d51a91905 100644 --- a/compose.yaml +++ b/compose.yaml @@ -4,18 +4,10 @@ services: restart: unless-stopped environment: SERVER_NAME: ${SERVER_NAME:-localhost}, php:80 - MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!} - MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!} TRUSTED_PROXIES: ${TRUSTED_PROXIES:-127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16} TRUSTED_HOSTS: ^${SERVER_NAME:-example\.com|localhost}|php$$ - # Run "composer require symfony/orm-pack" to install and configure Doctrine ORM - DATABASE_URL: postgresql://${POSTGRES_USER:-app}:${POSTGRES_PASSWORD:-!ChangeMe!}@database:5432/${POSTGRES_DB:-app}?serverVersion=${POSTGRES_VERSION:-15}&charset=${POSTGRES_CHARSET:-utf8} - # Run "composer require symfony/mercure-bundle" to install and configure the Mercure integration - MERCURE_URL: ${CADDY_MERCURE_URL:-http://php/.well-known/mercure} - MERCURE_PUBLIC_URL: https://${SERVER_NAME:-localhost}/.well-known/mercure - MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!} # The two next lines can be removed after initial installation - SYMFONY_VERSION: ${SYMFONY_VERSION:-} + LARAVEL_VERSION: ${LARAVEL_VERSION:-} STABILITY: ${STABILITY:-stable} volumes: - caddy_data:/data @@ -34,12 +26,6 @@ services: published: ${HTTP3_PORT:-443} protocol: udp -# Mercure is installed as a Caddy module, prevent the Flex recipe from installing another service -###> symfony/mercure-bundle ### -###< symfony/mercure-bundle ### - volumes: caddy_data: caddy_config: -###> symfony/mercure-bundle ### -###< symfony/mercure-bundle ### diff --git a/frankenphp/Caddyfile b/frankenphp/Caddyfile index 838393046..b52c27660 100644 --- a/frankenphp/Caddyfile +++ b/frankenphp/Caddyfile @@ -5,47 +5,15 @@ {$FRANKENPHP_CONFIG} } - # https://caddyserver.com/docs/caddyfile/directives#sorting-algorithm - order mercure after encode - order vulcain after reverse_proxy order php_server before file_server } {$CADDY_EXTRA_CONFIG} {$SERVER_NAME:localhost} { - log { - # Redact the authorization query parameter that can be set by Mercure - format filter { - wrap console - fields { - uri query { - replace authorization REDACTED - } - } - } - } - root * /app/public encode zstd br gzip - mercure { - # Transport to use (default to Bolt) - transport_url {$MERCURE_TRANSPORT_URL:bolt:///data/mercure.db} - # Publisher JWT key - publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG} - # Subscriber JWT key - subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG} - # Allow anonymous subscribers (double-check that it's what you want) - anonymous - # Enable the subscription API (double-check that it's what you want) - subscriptions - # Extra directives - {$MERCURE_EXTRA_DIRECTIVES} - } - - vulcain - {$CADDY_SERVER_EXTRA_DIRECTIVES} # Disable Topics tracking if not enabled explicitly: https://github.com/jkarlin/topics diff --git a/frankenphp/docker-entrypoint.sh b/frankenphp/docker-entrypoint.sh index bdddc3ac4..7de4e38b6 100755 --- a/frankenphp/docker-entrypoint.sh +++ b/frankenphp/docker-entrypoint.sh @@ -1,60 +1,21 @@ #!/bin/sh set -e -if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then +if [ "$1" = 'frankenphp' ]; then # Install the project the first time PHP is started # After the installation, the following block can be deleted if [ ! -f composer.json ]; then rm -Rf tmp/ - composer create-project "symfony/skeleton $SYMFONY_VERSION" tmp --stability="$STABILITY" --prefer-dist --no-progress --no-interaction --no-install + composer create-project "laravel/laravel $LARAVEL_VERSION" tmp --stability="$STABILITY" --prefer-dist --no-progress --no-interaction cd tmp cp -Rp . .. cd - rm -Rf tmp/ - - composer require "php:>=$PHP_VERSION" runtime/frankenphp-symfony - composer config --json extra.symfony.docker 'true' - - if grep -q ^DATABASE_URL= .env; then - echo "To finish the installation please press Ctrl+C to stop Docker Compose and run: docker compose up --build -d --wait" - sleep infinity - fi - fi - - if [ -z "$(ls -A 'vendor/' 2>/dev/null)" ]; then - composer install --prefer-dist --no-progress --no-interaction - fi - - if grep -q ^DATABASE_URL= .env; then - echo "Waiting for database to be ready..." - ATTEMPTS_LEFT_TO_REACH_DATABASE=60 - until [ $ATTEMPTS_LEFT_TO_REACH_DATABASE -eq 0 ] || DATABASE_ERROR=$(php bin/console dbal:run-sql -q "SELECT 1" 2>&1); do - if [ $? -eq 255 ]; then - # If the Doctrine command exits with 255, an unrecoverable error occurred - ATTEMPTS_LEFT_TO_REACH_DATABASE=0 - break - fi - sleep 1 - ATTEMPTS_LEFT_TO_REACH_DATABASE=$((ATTEMPTS_LEFT_TO_REACH_DATABASE - 1)) - echo "Still waiting for database to be ready... Or maybe the database is not reachable. $ATTEMPTS_LEFT_TO_REACH_DATABASE attempts left." - done - - if [ $ATTEMPTS_LEFT_TO_REACH_DATABASE -eq 0 ]; then - echo "The database is not up or not reachable:" - echo "$DATABASE_ERROR" - exit 1 - else - echo "The database is now ready and reachable" - fi - - if [ "$( find ./migrations -iname '*.php' -print -quit )" ]; then - php bin/console doctrine:migrations:migrate --no-interaction - fi fi - setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX var - setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX var + setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX storage bootstrap/cache + setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX storage bootstrap/cache fi exec docker-php-entrypoint "$@" diff --git a/frankenphp/worker.Caddyfile b/frankenphp/worker.Caddyfile deleted file mode 100644 index d384ae4cd..000000000 --- a/frankenphp/worker.Caddyfile +++ /dev/null @@ -1,4 +0,0 @@ -worker { - file ./public/index.php - env APP_RUNTIME Runtime\FrankenPhpSymfony\Runtime -} From 2a195941642cd5fa45c18b41d0cfd0adcaccfc53 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 16 Feb 2024 20:48:49 +0100 Subject: [PATCH 02/31] adapt for laravel --- .editorconfig | 52 ++++----------------------------- .gitattributes | 22 +++++--------- Dockerfile | 15 ++++------ compose.override.yaml | 4 --- compose.yaml | 16 +--------- frankenphp/Caddyfile | 32 -------------------- frankenphp/docker-entrypoint.sh | 47 +++-------------------------- frankenphp/worker.Caddyfile | 4 --- 8 files changed, 25 insertions(+), 167 deletions(-) delete mode 100644 frankenphp/worker.Caddyfile diff --git a/.editorconfig b/.editorconfig index 1ea821469..8f0de65c5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,58 +1,18 @@ -# EditorConfig helps developers define and maintain consistent -# coding styles between different editors and IDEs -# editorconfig.org - root = true [*] -# Change these settings to your own preference -indent_style = space -indent_size = 4 - -# We recommend you to keep these unchanged -end_of_line = lf charset = utf-8 -trim_trailing_whitespace = true +end_of_line = lf +indent_size = 4 +indent_style = space insert_final_newline = true - -[*.{js,html,ts,tsx}] -indent_size = 2 - -[*.json] -indent_size = 2 +trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false -[*.sh] -indent_style = tab - -[*.xml{,.dist}] -indent_style = space -indent_size = 4 - -[*.{yaml,yml}] -trim_trailing_whitespace = false - -[.github/workflows/*.yml] +[*.{yml,yaml}] indent_size = 2 -[.gitmodules] -indent_style = tab - -[.php_cs{,.dist}] -indent_style = space -indent_size = 4 - -[composer.json] +[docker-compose.yml] indent_size = 4 - -[{,docker-}compose{,.*}.{yaml,yml}] -indent_style = space -indent_size = 2 - -[{,*.*}Dockerfile] -indent_style = tab - -[{,*.*}Caddyfile] -indent_style = tab diff --git a/.gitattributes b/.gitattributes index 642c91f2d..fcb21d396 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,17 +1,11 @@ * text=auto eol=lf -*.conf text eol=lf -*.html text eol=lf -*.ini text eol=lf -*.js text eol=lf -*.json text eol=lf -*.md text eol=lf -*.php text eol=lf -*.sh text eol=lf -*.yaml text eol=lf -*.yml text eol=lf -bin/console text eol=lf -composer.lock text eol=lf merge=ours +*.blade.php diff=html +*.css diff=css +*.html diff=html +*.md diff=markdown +*.php diff=php -*.ico binary -*.png binary +/.github export-ignore +CHANGELOG.md export-ignore +.styleci.yml export-ignore diff --git a/Dockerfile b/Dockerfile index c19deb692..9711345a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,7 +50,7 @@ CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile" ] FROM frankenphp_base AS frankenphp_dev ENV APP_ENV=dev XDEBUG_MODE=off -VOLUME /app/var/ +VOLUME /app/storage/ /app/bootstrap/cache/ RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" @@ -67,15 +67,13 @@ CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile", "--watch" ] FROM frankenphp_base AS frankenphp_prod ENV APP_ENV=prod -ENV FRANKENPHP_CONFIG="import worker.Caddyfile" RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" COPY --link frankenphp/conf.d/app.prod.ini $PHP_INI_DIR/conf.d/ -COPY --link frankenphp/worker.Caddyfile /etc/caddy/worker.Caddyfile # prevent the reinstallation of vendors at every changes in the source code -COPY --link composer.* symfony.* ./ +COPY --link composer.* ./ RUN set -eux; \ composer install --no-cache --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress @@ -84,8 +82,7 @@ COPY --link . ./ RUN rm -Rf frankenphp/ RUN set -eux; \ - mkdir -p var/cache var/log; \ - composer dump-autoload --classmap-authoritative --no-dev; \ - composer dump-env prod; \ - composer run-script --no-dev post-install-cmd; \ - chmod +x bin/console; sync; + mkdir -p storage/framework/{sessions,views,cache,testing} storage/logs bootstrap/cache; \ + chmod -R a+rw storage; \ + composer install --classmap-authoritative --no-interaction --no-ansi --no-dev; \ + php artisan storage:link; diff --git a/compose.override.yaml b/compose.override.yaml index 5f141b1f1..8df70faca 100644 --- a/compose.override.yaml +++ b/compose.override.yaml @@ -12,13 +12,9 @@ services: # from the bind-mount for better performance by enabling the next line: #- /app/vendor environment: - MERCURE_EXTRA_DIRECTIVES: demo # See https://xdebug.org/docs/all_settings#mode XDEBUG_MODE: "${XDEBUG_MODE:-off}" extra_hosts: # Ensure that host.docker.internal is correctly defined on Linux - host.docker.internal:host-gateway tty: true - -###> symfony/mercure-bundle ### -###< symfony/mercure-bundle ### diff --git a/compose.yaml b/compose.yaml index 43a079003..d51a91905 100644 --- a/compose.yaml +++ b/compose.yaml @@ -4,18 +4,10 @@ services: restart: unless-stopped environment: SERVER_NAME: ${SERVER_NAME:-localhost}, php:80 - MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!} - MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!} TRUSTED_PROXIES: ${TRUSTED_PROXIES:-127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16} TRUSTED_HOSTS: ^${SERVER_NAME:-example\.com|localhost}|php$$ - # Run "composer require symfony/orm-pack" to install and configure Doctrine ORM - DATABASE_URL: postgresql://${POSTGRES_USER:-app}:${POSTGRES_PASSWORD:-!ChangeMe!}@database:5432/${POSTGRES_DB:-app}?serverVersion=${POSTGRES_VERSION:-15}&charset=${POSTGRES_CHARSET:-utf8} - # Run "composer require symfony/mercure-bundle" to install and configure the Mercure integration - MERCURE_URL: ${CADDY_MERCURE_URL:-http://php/.well-known/mercure} - MERCURE_PUBLIC_URL: https://${SERVER_NAME:-localhost}/.well-known/mercure - MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!} # The two next lines can be removed after initial installation - SYMFONY_VERSION: ${SYMFONY_VERSION:-} + LARAVEL_VERSION: ${LARAVEL_VERSION:-} STABILITY: ${STABILITY:-stable} volumes: - caddy_data:/data @@ -34,12 +26,6 @@ services: published: ${HTTP3_PORT:-443} protocol: udp -# Mercure is installed as a Caddy module, prevent the Flex recipe from installing another service -###> symfony/mercure-bundle ### -###< symfony/mercure-bundle ### - volumes: caddy_data: caddy_config: -###> symfony/mercure-bundle ### -###< symfony/mercure-bundle ### diff --git a/frankenphp/Caddyfile b/frankenphp/Caddyfile index 838393046..b52c27660 100644 --- a/frankenphp/Caddyfile +++ b/frankenphp/Caddyfile @@ -5,47 +5,15 @@ {$FRANKENPHP_CONFIG} } - # https://caddyserver.com/docs/caddyfile/directives#sorting-algorithm - order mercure after encode - order vulcain after reverse_proxy order php_server before file_server } {$CADDY_EXTRA_CONFIG} {$SERVER_NAME:localhost} { - log { - # Redact the authorization query parameter that can be set by Mercure - format filter { - wrap console - fields { - uri query { - replace authorization REDACTED - } - } - } - } - root * /app/public encode zstd br gzip - mercure { - # Transport to use (default to Bolt) - transport_url {$MERCURE_TRANSPORT_URL:bolt:///data/mercure.db} - # Publisher JWT key - publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG} - # Subscriber JWT key - subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG} - # Allow anonymous subscribers (double-check that it's what you want) - anonymous - # Enable the subscription API (double-check that it's what you want) - subscriptions - # Extra directives - {$MERCURE_EXTRA_DIRECTIVES} - } - - vulcain - {$CADDY_SERVER_EXTRA_DIRECTIVES} # Disable Topics tracking if not enabled explicitly: https://github.com/jkarlin/topics diff --git a/frankenphp/docker-entrypoint.sh b/frankenphp/docker-entrypoint.sh index bdddc3ac4..7de4e38b6 100755 --- a/frankenphp/docker-entrypoint.sh +++ b/frankenphp/docker-entrypoint.sh @@ -1,60 +1,21 @@ #!/bin/sh set -e -if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then +if [ "$1" = 'frankenphp' ]; then # Install the project the first time PHP is started # After the installation, the following block can be deleted if [ ! -f composer.json ]; then rm -Rf tmp/ - composer create-project "symfony/skeleton $SYMFONY_VERSION" tmp --stability="$STABILITY" --prefer-dist --no-progress --no-interaction --no-install + composer create-project "laravel/laravel $LARAVEL_VERSION" tmp --stability="$STABILITY" --prefer-dist --no-progress --no-interaction cd tmp cp -Rp . .. cd - rm -Rf tmp/ - - composer require "php:>=$PHP_VERSION" runtime/frankenphp-symfony - composer config --json extra.symfony.docker 'true' - - if grep -q ^DATABASE_URL= .env; then - echo "To finish the installation please press Ctrl+C to stop Docker Compose and run: docker compose up --build -d --wait" - sleep infinity - fi - fi - - if [ -z "$(ls -A 'vendor/' 2>/dev/null)" ]; then - composer install --prefer-dist --no-progress --no-interaction - fi - - if grep -q ^DATABASE_URL= .env; then - echo "Waiting for database to be ready..." - ATTEMPTS_LEFT_TO_REACH_DATABASE=60 - until [ $ATTEMPTS_LEFT_TO_REACH_DATABASE -eq 0 ] || DATABASE_ERROR=$(php bin/console dbal:run-sql -q "SELECT 1" 2>&1); do - if [ $? -eq 255 ]; then - # If the Doctrine command exits with 255, an unrecoverable error occurred - ATTEMPTS_LEFT_TO_REACH_DATABASE=0 - break - fi - sleep 1 - ATTEMPTS_LEFT_TO_REACH_DATABASE=$((ATTEMPTS_LEFT_TO_REACH_DATABASE - 1)) - echo "Still waiting for database to be ready... Or maybe the database is not reachable. $ATTEMPTS_LEFT_TO_REACH_DATABASE attempts left." - done - - if [ $ATTEMPTS_LEFT_TO_REACH_DATABASE -eq 0 ]; then - echo "The database is not up or not reachable:" - echo "$DATABASE_ERROR" - exit 1 - else - echo "The database is now ready and reachable" - fi - - if [ "$( find ./migrations -iname '*.php' -print -quit )" ]; then - php bin/console doctrine:migrations:migrate --no-interaction - fi fi - setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX var - setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX var + setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX storage bootstrap/cache + setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX storage bootstrap/cache fi exec docker-php-entrypoint "$@" diff --git a/frankenphp/worker.Caddyfile b/frankenphp/worker.Caddyfile deleted file mode 100644 index d384ae4cd..000000000 --- a/frankenphp/worker.Caddyfile +++ /dev/null @@ -1,4 +0,0 @@ -worker { - file ./public/index.php - env APP_RUNTIME Runtime\FrankenPhpSymfony\Runtime -} From d1e2282b42a29be2209246157e346ead66fb4456 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 16 Feb 2024 21:20:11 +0100 Subject: [PATCH 03/31] adapt for laravel --- README.md | 89 ++++++++++++++++++++++--------------------------------- 1 file changed, 36 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index 1a4c26ba3..a48435358 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,49 @@ -

Laravel Logo

+# Symfony Docker -

-Build Status -Total Downloads -Latest Stable Version -License -

+A [Docker](https://www.docker.com/)-based installer and runtime for the [Symfony](https://symfony.com) web framework, +with [FrankenPHP](https://frankenphp.dev) and [Caddy](https://caddyserver.com/) inside! -## About Laravel +![CI](https://github.com/dunglas/symfony-docker/workflows/CI/badge.svg) -Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: +## Getting Started -- [Simple, fast routing engine](https://laravel.com/docs/routing). -- [Powerful dependency injection container](https://laravel.com/docs/container). -- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. -- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). -- Database agnostic [schema migrations](https://laravel.com/docs/migrations). -- [Robust background job processing](https://laravel.com/docs/queues). -- [Real-time event broadcasting](https://laravel.com/docs/broadcasting). +1. If not already done, [install Docker Compose](https://docs.docker.com/compose/install/) (v2.10+) +2. Run `docker compose build --no-cache` to build fresh images +3. Run `docker compose up --pull always -d --wait` to start the project +4. Open `https://localhost` in your favorite web browser and [accept the auto-generated TLS certificate](https://stackoverflow.com/a/15076602/1352334) +5. Run `docker compose down --remove-orphans` to stop the Docker containers. -Laravel is accessible, powerful, and provides tools required for large, robust applications. +## Features -## Learning Laravel +* Production, development and CI ready +* Just 1 service by default +* Blazing-fast performance thanks to [the worker mode of FrankenPHP](https://github.com/dunglas/frankenphp/blob/main/docs/worker.md) (automatically enabled in prod mode) +* [Installation of extra Docker Compose services](docs/extra-services.md) with Symfony Flex +* Automatic HTTPS (in dev and prod) +* HTTP/3 and [Early Hints](https://symfony.com/blog/new-in-symfony-6-3-early-hints) support +* Real-time messaging thanks to a built-in [Mercure hub](https://symfony.com/doc/current/mercure.html) +* [Vulcain](https://vulcain.rocks) support +* Native [XDebug](docs/xdebug.md) integration +* Super-readable configuration -Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. +**Enjoy!** -You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch. +## Docs -If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. +1. [Build options](docs/build.md) +2. [Using Symfony Docker with an existing project](docs/existing-project.md) +3. [Support for extra services](docs/extra-services.md) +4. [Deploying in production](docs/production.md) +5. [Debugging with Xdebug](docs/xdebug.md) +6. [TLS Certificates](docs/tls.md) +7. [Using a Makefile](docs/makefile.md) +8. [Troubleshooting](docs/troubleshooting.md) +9. [Updating the template](docs/updating.md) -## Laravel Sponsors - -We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com). - -### Premium Partners - -- **[Vehikl](https://vehikl.com/)** -- **[Tighten Co.](https://tighten.co)** -- **[WebReinvent](https://webreinvent.com/)** -- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** -- **[64 Robots](https://64robots.com)** -- **[Curotec](https://www.curotec.com/services/technologies/laravel/)** -- **[Cyber-Duck](https://cyber-duck.co.uk)** -- **[DevSquad](https://devsquad.com/hire-laravel-developers)** -- **[Jump24](https://jump24.co.uk)** -- **[Redberry](https://redberry.international/laravel/)** -- **[Active Logic](https://activelogic.com)** -- **[byte5](https://byte5.de)** -- **[OP.GG](https://op.gg)** - -## Contributing - -Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). - -## Code of Conduct - -In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). - -## Security Vulnerabilities +## License -If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. +Symfony Docker is available under the MIT License. -## License +## Credits -The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). +Created by [Kévin Dunglas](https://dunglas.dev), co-maintained by [Maxime Helias](https://twitter.com/maxhelias) and sponsored by [Les-Tilleuls.coop](https://les-tilleuls.coop). From 20abf09e5360e65afd8562d941910ef138de7124 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 16 Feb 2024 21:22:21 +0100 Subject: [PATCH 04/31] update README.md --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a48435358..5621d345c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Symfony Docker -A [Docker](https://www.docker.com/)-based installer and runtime for the [Symfony](https://symfony.com) web framework, +A [Docker](https://www.docker.com/)-based installer and runtime for the [Laravel](https://laravel.com) web framework, with [FrankenPHP](https://frankenphp.dev) and [Caddy](https://caddyserver.com/) inside! ![CI](https://github.com/dunglas/symfony-docker/workflows/CI/badge.svg) @@ -18,11 +18,9 @@ with [FrankenPHP](https://frankenphp.dev) and [Caddy](https://caddyserver.com/) * Production, development and CI ready * Just 1 service by default * Blazing-fast performance thanks to [the worker mode of FrankenPHP](https://github.com/dunglas/frankenphp/blob/main/docs/worker.md) (automatically enabled in prod mode) -* [Installation of extra Docker Compose services](docs/extra-services.md) with Symfony Flex +* [Installation of extra Docker Compose services](docs/extra-services.md) * Automatic HTTPS (in dev and prod) * HTTP/3 and [Early Hints](https://symfony.com/blog/new-in-symfony-6-3-early-hints) support -* Real-time messaging thanks to a built-in [Mercure hub](https://symfony.com/doc/current/mercure.html) -* [Vulcain](https://vulcain.rocks) support * Native [XDebug](docs/xdebug.md) integration * Super-readable configuration @@ -42,8 +40,8 @@ with [FrankenPHP](https://frankenphp.dev) and [Caddy](https://caddyserver.com/) ## License -Symfony Docker is available under the MIT License. +Laravel Docker is available under the MIT License. ## Credits -Created by [Kévin Dunglas](https://dunglas.dev), co-maintained by [Maxime Helias](https://twitter.com/maxhelias) and sponsored by [Les-Tilleuls.coop](https://les-tilleuls.coop). +Original created by [Kévin Dunglas](https://dunglas.dev), co-maintained by [Maxime Helias](https://twitter.com/maxhelias) and sponsored by [Les-Tilleuls.coop](https://les-tilleuls.coop). From 3bc1d9f88761a6675c7325194eef4451d02a04b2 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 16 Feb 2024 21:22:48 +0100 Subject: [PATCH 05/31] update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5621d345c..654856ce2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Symfony Docker +# Laravel Docker A [Docker](https://www.docker.com/)-based installer and runtime for the [Laravel](https://laravel.com) web framework, with [FrankenPHP](https://frankenphp.dev) and [Caddy](https://caddyserver.com/) inside! From 502e74b6e94a955070b1381fa52d5515405ce2c5 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 14 Jun 2024 17:35:22 +0200 Subject: [PATCH 06/31] move alpine to debian --- Dockerfile | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9711345a4..c0e535c7c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ #syntax=docker/dockerfile:1.4 # Versions -FROM dunglas/frankenphp:1-alpine AS frankenphp_upstream +FROM dunglas/frankenphp:1-php8.3 AS frankenphp_upstream # The different stages of this Dockerfile are meant to be built into separate images # https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage @@ -13,14 +13,16 @@ FROM frankenphp_upstream AS frankenphp_base WORKDIR /app +VOLUME /app/storage/ + # persistent / runtime deps -# hadolint ignore=DL3018 -RUN apk add --no-cache \ - acl \ - file \ - gettext \ - git \ - ; +# hadolint ignore=DL3008 +RUN apt-get update && apt-get install -y --no-install-recommends \ + acl \ + file \ + gettext \ + git \ + && rm -rf /var/lib/apt/lists/* RUN set -eux; \ install-php-extensions \ @@ -50,7 +52,6 @@ CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile" ] FROM frankenphp_base AS frankenphp_dev ENV APP_ENV=dev XDEBUG_MODE=off -VOLUME /app/storage/ /app/bootstrap/cache/ RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" From 9b2d8914f238145a04f4b731cdb5bf07dfc6dca9 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 14 Jun 2024 17:38:37 +0200 Subject: [PATCH 07/31] add complete arg --- frankenphp/docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frankenphp/docker-entrypoint.sh b/frankenphp/docker-entrypoint.sh index 7de4e38b6..0f1632c5b 100755 --- a/frankenphp/docker-entrypoint.sh +++ b/frankenphp/docker-entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/sh set -e -if [ "$1" = 'frankenphp' ]; then +if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then # Install the project the first time PHP is started # After the installation, the following block can be deleted if [ ! -f composer.json ]; then From 5633aa0b68139629f6dcd4955d575a4cc109a90a Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 14 Jun 2024 17:38:46 +0200 Subject: [PATCH 08/31] update app.ini --- frankenphp/conf.d/app.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/frankenphp/conf.d/app.ini b/frankenphp/conf.d/app.ini index 501fa84f8..79a17dd81 100644 --- a/frankenphp/conf.d/app.ini +++ b/frankenphp/conf.d/app.ini @@ -1,4 +1,3 @@ -variables_order = EGPCS expose_php = 0 date.timezone = UTC apc.enable_cli = 1 From ea029ce32883e478d511a0620c4417ebc9e1c0f0 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 14 Jun 2024 17:39:27 +0200 Subject: [PATCH 09/31] remove bootstrap --- frankenphp/docker-entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frankenphp/docker-entrypoint.sh b/frankenphp/docker-entrypoint.sh index 0f1632c5b..0115cf82f 100755 --- a/frankenphp/docker-entrypoint.sh +++ b/frankenphp/docker-entrypoint.sh @@ -14,8 +14,8 @@ if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then rm -Rf tmp/ fi - setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX storage bootstrap/cache - setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX storage bootstrap/cache + setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX storage + setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX storage fi exec docker-php-entrypoint "$@" From 13e0483847eb7fcba371c8ab0a4ec1e89ff2b54b Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 14 Jun 2024 17:42:06 +0200 Subject: [PATCH 10/31] move install --- frankenphp/docker-entrypoint.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frankenphp/docker-entrypoint.sh b/frankenphp/docker-entrypoint.sh index 0115cf82f..14c45c43b 100755 --- a/frankenphp/docker-entrypoint.sh +++ b/frankenphp/docker-entrypoint.sh @@ -6,7 +6,7 @@ if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then # After the installation, the following block can be deleted if [ ! -f composer.json ]; then rm -Rf tmp/ - composer create-project "laravel/laravel $LARAVEL_VERSION" tmp --stability="$STABILITY" --prefer-dist --no-progress --no-interaction + composer create-project "laravel/laravel $LARAVEL_VERSION" tmp --stability="$STABILITY" --prefer-dist --no-progress --no-interaction --no-install cd tmp cp -Rp . .. @@ -14,6 +14,10 @@ if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then rm -Rf tmp/ fi + if [ -z "$(ls -A 'vendor/' 2>/dev/null)" ]; then + composer install --prefer-dist --no-progress --no-interaction + fi + setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX storage setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX storage fi From 1aaa8561f6b7707feb2cdae95d412301aa4a88b5 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 14 Jun 2024 18:38:20 +0200 Subject: [PATCH 11/31] =?UTF-8?q?adjust=20script=20for=20ignore=20installa?= =?UTF-8?q?tion=20and=20script=20"=C3=A0=20certains=20endroits"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frankenphp/docker-entrypoint.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frankenphp/docker-entrypoint.sh b/frankenphp/docker-entrypoint.sh index 14c45c43b..2bfbbd07a 100755 --- a/frankenphp/docker-entrypoint.sh +++ b/frankenphp/docker-entrypoint.sh @@ -6,16 +6,20 @@ if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then # After the installation, the following block can be deleted if [ ! -f composer.json ]; then rm -Rf tmp/ - composer create-project "laravel/laravel $LARAVEL_VERSION" tmp --stability="$STABILITY" --prefer-dist --no-progress --no-interaction --no-install + composer create-project "laravel/laravel $LARAVEL_VERSION" tmp --stability="$STABILITY" --remove-vcs --no-scripts --prefer-dist --no-progress --no-interaction --no-install cd tmp cp -Rp . .. cd - rm -Rf tmp/ + + composer require "php:>=$PHP_VERSION" --no-scripts --no-install fi if [ -z "$(ls -A 'vendor/' 2>/dev/null)" ]; then + composer run-script post-root-package-install composer install --prefer-dist --no-progress --no-interaction + composer run-script post-create-project-cmd fi setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX storage From 5de3ab0873e96a426b3a8ad31ba8cc3929e8a885 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 14 Jun 2024 19:53:37 +0200 Subject: [PATCH 12/31] standard of laravel for APP_ENV --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c0e535c7c..d8005cc9f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -51,7 +51,7 @@ CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile" ] # Dev FrankenPHP image FROM frankenphp_base AS frankenphp_dev -ENV APP_ENV=dev XDEBUG_MODE=off +ENV APP_ENV=local XDEBUG_MODE=off RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" From 96352ad4808ae4d12cabfdb3e5cdbc7fed76dbfb Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 14 Jun 2024 21:18:52 +0200 Subject: [PATCH 13/31] add node for prod --- Dockerfile | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index d8005cc9f..214eee4ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -64,6 +64,27 @@ COPY --link frankenphp/conf.d/app.dev.ini $PHP_INI_DIR/conf.d/ CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile", "--watch" ] +ARG NODE_VERSION=20-alpine + +FROM node:${NODE_VERSION} AS build + +WORKDIR /app + +RUN npm config set update-notifier false && npm set progress=false + +COPY --link package*.json ./ + +RUN if [ -f $ROOT/package-lock.json ]; \ + then \ + npm ci --loglevel=error --no-audit; \ + else \ + npm install --loglevel=error --no-audit; \ + fi + +COPY --link . . + +RUN npm run build + # Prod FrankenPHP image FROM frankenphp_base AS frankenphp_prod @@ -82,8 +103,14 @@ RUN set -eux; \ COPY --link . ./ RUN rm -Rf frankenphp/ +# copy build assets +COPY --link --from=build /app/public ./public + RUN set -eux; \ - mkdir -p storage/framework/{sessions,views,cache,testing} storage/logs bootstrap/cache; \ + mkdir -p storage/framework/{sessions,views,cache,testing} \ + storage/logs \ + bootstrap/cache; \ chmod -R a+rw storage; \ composer install --classmap-authoritative --no-interaction --no-ansi --no-dev; \ - php artisan storage:link; + composer cache:clear; \ + php artisan optimize; sync; From 686b565408591266e3c08761d14fa4750dfb54f9 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 14 Jun 2024 21:39:39 +0200 Subject: [PATCH 14/31] fix node version --- Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 214eee4ac..8e86e647a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -64,9 +64,7 @@ COPY --link frankenphp/conf.d/app.dev.ini $PHP_INI_DIR/conf.d/ CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile", "--watch" ] -ARG NODE_VERSION=20-alpine - -FROM node:${NODE_VERSION} AS build +FROM node:20-alpine AS build WORKDIR /app From 8aab4442226071b2e04f3695cba0426abca50ba5 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 14 Jun 2024 23:04:03 +0200 Subject: [PATCH 15/31] add node for dev --- Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8e86e647a..b227fcdf1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,6 @@ FROM dunglas/frankenphp:1-php8.3 AS frankenphp_upstream # https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage # https://docs.docker.com/compose/compose-file/#target - # Base FrankenPHP image FROM frankenphp_upstream AS frankenphp_base @@ -55,6 +54,11 @@ ENV APP_ENV=local XDEBUG_MODE=off RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" +RUN curl -fsSL https://deb.nodesource.com/setup_lts.x -o nodesource_setup.sh; \ + bash nodesource_setup.sh; \ + apt-get install -y nodejs; \ + rm nodesource_setup.sh; + RUN set -eux; \ install-php-extensions \ xdebug \ From 6d2921d803a5267ace14871b1c486a8382878a3e Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 14 Jun 2024 23:10:18 +0200 Subject: [PATCH 16/31] write for laravel --- docs/makefile.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/makefile.md b/docs/makefile.md index 90f19a5d4..46d027110 100644 --- a/docs/makefile.md +++ b/docs/makefile.md @@ -42,13 +42,13 @@ PHP_CONT = $(DOCKER_COMP) exec php # Executables PHP = $(PHP_CONT) php COMPOSER = $(PHP_CONT) composer -SYMFONY = $(PHP) bin/console +LARAVEL = $(PHP) artisan # Misc .DEFAULT_GOAL = help -.PHONY : help build up start down logs sh composer vendor sf cc test +.PHONY : help build up start down logs sh composer vendor a cc test -## —— 🎵 🐳 The Symfony Docker Makefile 🐳 🎵 —————————————————————————————————— +## —— 🎵 🐳 The Laravel Docker Makefile 🐳 🎵 —————————————————————————————————— help: ## Outputs this help screen @grep -E '(^[a-zA-Z0-9\./_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/' @@ -76,7 +76,7 @@ test: ## Start tests with phpunit, pass the parameter "c=" to add options to php ## —— Composer 🧙 —————————————————————————————————————————————————————————————— -composer: ## Run composer, pass the parameter "c=" to run a given command, example: make composer c='req symfony/orm-pack' +composer: ## Run composer, pass the parameter "c=" to run a given command, example: make composer c='req laravel/breeze --dev' @$(eval c ?=) @$(COMPOSER) $(c) @@ -84,11 +84,11 @@ vendor: ## Install vendors according to the current composer.lock file vendor: c=install --prefer-dist --no-dev --no-progress --no-scripts --no-interaction vendor: composer -## —— Symfony 🎵 ——————————————————————————————————————————————————————————————— -sf: ## List all Symfony commands or pass the parameter "c=" to run a given command, example: make sf c=about +## —— Laravel 🟥 ——————————————————————————————————————————————————————————————— +a: ## List all Laravel commands or pass the parameter "c=" to run a given command, example: make sf c=about @$(eval c ?=) - @$(SYMFONY) $(c) + @$(LARAVEL) $(c) cc: c=c:c ## Clear the cache -cc: sf +cc: a ``` From 5ce4d833fbe34e84fa0d21d50759f3b4ecdcf90d Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 15 Jun 2024 00:03:59 +0200 Subject: [PATCH 17/31] write for laravel --- docs/makefile.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/makefile.md b/docs/makefile.md index 46d027110..c19c11a62 100644 --- a/docs/makefile.md +++ b/docs/makefile.md @@ -85,7 +85,7 @@ vendor: c=install --prefer-dist --no-dev --no-progress --no-scripts --no-interac vendor: composer ## —— Laravel 🟥 ——————————————————————————————————————————————————————————————— -a: ## List all Laravel commands or pass the parameter "c=" to run a given command, example: make sf c=about +a: ## List all Laravel commands or pass the parameter "c=" to run a given command, example: make a c=about @$(eval c ?=) @$(LARAVEL) $(c) From 196bdf9ba39f1dea1c87e9fa4082cb317e0f943e Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 15 Jun 2024 00:04:09 +0200 Subject: [PATCH 18/31] switch bin/console to artisan --- frankenphp/docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frankenphp/docker-entrypoint.sh b/frankenphp/docker-entrypoint.sh index 2bfbbd07a..0935d24ce 100755 --- a/frankenphp/docker-entrypoint.sh +++ b/frankenphp/docker-entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/sh set -e -if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then +if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'artisan' ]; then # Install the project the first time PHP is started # After the installation, the following block can be deleted if [ ! -f composer.json ]; then From 3980ffbf915125f65bb042f8a46b766f22fc7ac3 Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 15 Jun 2024 01:41:18 +0200 Subject: [PATCH 19/31] add node env --- compose.override.yaml | 5 +++++ docs/makefile.md | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/compose.override.yaml b/compose.override.yaml index 8df70faca..2cf5fab78 100644 --- a/compose.override.yaml +++ b/compose.override.yaml @@ -14,7 +14,12 @@ services: environment: # See https://xdebug.org/docs/all_settings#mode XDEBUG_MODE: "${XDEBUG_MODE:-off}" + NODE_ENV: development extra_hosts: # Ensure that host.docker.internal is correctly defined on Linux - host.docker.internal:host-gateway tty: true + ports: + - target: 5173 + published: 5173 + protocol: tcp diff --git a/docs/makefile.md b/docs/makefile.md index c19c11a62..f032d6787 100644 --- a/docs/makefile.md +++ b/docs/makefile.md @@ -42,11 +42,12 @@ PHP_CONT = $(DOCKER_COMP) exec php # Executables PHP = $(PHP_CONT) php COMPOSER = $(PHP_CONT) composer +NPM = $(PHP_CONT) npm LARAVEL = $(PHP) artisan # Misc .DEFAULT_GOAL = help -.PHONY : help build up start down logs sh composer vendor a cc test +.PHONY : help build up start down logs sh composer vendor npm dev a cc test ## —— 🎵 🐳 The Laravel Docker Makefile 🐳 🎵 —————————————————————————————————— help: ## Outputs this help screen @@ -84,6 +85,14 @@ vendor: ## Install vendors according to the current composer.lock file vendor: c=install --prefer-dist --no-dev --no-progress --no-scripts --no-interaction vendor: composer +## —— Npm 🟩 —————————————————————————————————————————————————————————————— +npm: ## Run npm, pass the parameter "c=" to run a given command, example: make npm c='install' + @$(eval c ?=) + @$(NPM) $(c) + +dev: ## Run npm run dev + @$(NPM) run dev + ## —— Laravel 🟥 ——————————————————————————————————————————————————————————————— a: ## List all Laravel commands or pass the parameter "c=" to run a given command, example: make a c=about @$(eval c ?=) From 6b4c6a164611e6748471fd79470816c0b6549f91 Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 15 Jun 2024 08:42:58 +0200 Subject: [PATCH 20/31] add volume for persistent data --- Dockerfile | 2 -- compose.prod.yaml | 4 ---- compose.yaml | 4 ++++ frankenphp/docker-entrypoint.sh | 2 ++ 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index b227fcdf1..97491c0ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,8 +12,6 @@ FROM frankenphp_upstream AS frankenphp_base WORKDIR /app -VOLUME /app/storage/ - # persistent / runtime deps # hadolint ignore=DL3008 RUN apt-get update && apt-get install -y --no-install-recommends \ diff --git a/compose.prod.yaml b/compose.prod.yaml index f0db05da6..d9dcd9db6 100644 --- a/compose.prod.yaml +++ b/compose.prod.yaml @@ -4,7 +4,3 @@ services: build: context: . target: frankenphp_prod - environment: - APP_SECRET: ${APP_SECRET} - MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET} - MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET} diff --git a/compose.yaml b/compose.yaml index d51a91905..17737938c 100644 --- a/compose.yaml +++ b/compose.yaml @@ -12,6 +12,8 @@ services: volumes: - caddy_data:/data - caddy_config:/config + - storage_data:/app/storage + - cache_data:/app/bootstrap/cache ports: # HTTP - target: 80 @@ -29,3 +31,5 @@ services: volumes: caddy_data: caddy_config: + storage_data: + cache_data: diff --git a/frankenphp/docker-entrypoint.sh b/frankenphp/docker-entrypoint.sh index 0935d24ce..9671c3bf3 100755 --- a/frankenphp/docker-entrypoint.sh +++ b/frankenphp/docker-entrypoint.sh @@ -24,6 +24,8 @@ if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'artisan' ]; then setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX storage setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX storage + setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX bootstrap/cache + setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX bootstrap/cache fi exec docker-php-entrypoint "$@" From adbcb6d80ef1ab7f20607e9a0ef384f6b5f156aa Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 15 Jun 2024 09:10:44 +0200 Subject: [PATCH 21/31] fix command not found for laravel --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 97491c0ae..008deeb20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -112,5 +112,5 @@ RUN set -eux; \ bootstrap/cache; \ chmod -R a+rw storage; \ composer install --classmap-authoritative --no-interaction --no-ansi --no-dev; \ - composer cache:clear; \ + php artisan storage:link; \ php artisan optimize; sync; From 890a0e634a8db5c294dad9912e418a90b856c9f3 Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 15 Jun 2024 09:20:49 +0200 Subject: [PATCH 22/31] APP_ENV for production standard laravel --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 008deeb20..b40c3986f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -88,7 +88,7 @@ RUN npm run build # Prod FrankenPHP image FROM frankenphp_base AS frankenphp_prod -ENV APP_ENV=prod +ENV APP_ENV=production RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" From b62e4570505f381c85ab6dc06301502acb4dbb1b Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 15 Jun 2024 09:29:02 +0200 Subject: [PATCH 23/31] fix composer install and artisan optimize for production --- Dockerfile | 8 +++----- frankenphp/docker-entrypoint.sh | 5 +++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index b40c3986f..80be834bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -97,7 +97,8 @@ COPY --link frankenphp/conf.d/app.prod.ini $PHP_INI_DIR/conf.d/ # prevent the reinstallation of vendors at every changes in the source code COPY --link composer.* ./ RUN set -eux; \ - composer install --no-cache --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress + composer install --classmap-authoritative --no-interaction --no-ansi --no-dev; \ + composer clear-cache; \ # copy sources COPY --link . ./ @@ -110,7 +111,4 @@ RUN set -eux; \ mkdir -p storage/framework/{sessions,views,cache,testing} \ storage/logs \ bootstrap/cache; \ - chmod -R a+rw storage; \ - composer install --classmap-authoritative --no-interaction --no-ansi --no-dev; \ - php artisan storage:link; \ - php artisan optimize; sync; + chmod -R a+rw storage; sync; diff --git a/frankenphp/docker-entrypoint.sh b/frankenphp/docker-entrypoint.sh index 9671c3bf3..f7953cf17 100755 --- a/frankenphp/docker-entrypoint.sh +++ b/frankenphp/docker-entrypoint.sh @@ -26,6 +26,11 @@ if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'artisan' ]; then setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX storage setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX bootstrap/cache setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX bootstrap/cache + + if [ "$APP_ENV" = 'production' ]; then + php artisan storage:link + php artisan optimize + fi fi exec docker-php-entrypoint "$@" From 0904e44bae68306bac04d939cc0e1cf1f486a5ce Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 15 Jun 2024 10:28:31 +0200 Subject: [PATCH 24/31] fix composer install and artisan optimize for production --- Dockerfile | 29 +++++++++++++++++++++++------ frankenphp/docker-entrypoint.sh | 5 ----- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 80be834bc..9f344d78d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -96,9 +96,15 @@ COPY --link frankenphp/conf.d/app.prod.ini $PHP_INI_DIR/conf.d/ # prevent the reinstallation of vendors at every changes in the source code COPY --link composer.* ./ + RUN set -eux; \ - composer install --classmap-authoritative --no-interaction --no-ansi --no-dev; \ - composer clear-cache; \ + composer install \ + --no-dev \ + --no-interaction \ + --no-autoloader \ + --no-ansi \ + --no-scripts \ + --audit; # copy sources COPY --link . ./ @@ -108,7 +114,18 @@ RUN rm -Rf frankenphp/ COPY --link --from=build /app/public ./public RUN set -eux; \ - mkdir -p storage/framework/{sessions,views,cache,testing} \ - storage/logs \ - bootstrap/cache; \ - chmod -R a+rw storage; sync; + mkdir -p storage/framework/sessions; \ + mkdir -p storage/framework/views; \ + mkdir -p storage/framework/cache; \ + mkdir -p storage/framework/testing; \ + mkdir -p storage/logs; \ + mkdir -p bootstrap/cache; \ + chmod -R a+rw storage; \ + composer install \ + --classmap-authoritative \ + --no-interaction \ + --no-ansi \ + --no-dev; \ + composer clear-cache; \ + php artisan storage:link; \ + php artisan optimize; sync; diff --git a/frankenphp/docker-entrypoint.sh b/frankenphp/docker-entrypoint.sh index f7953cf17..9671c3bf3 100755 --- a/frankenphp/docker-entrypoint.sh +++ b/frankenphp/docker-entrypoint.sh @@ -26,11 +26,6 @@ if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'artisan' ]; then setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX storage setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX bootstrap/cache setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX bootstrap/cache - - if [ "$APP_ENV" = 'production' ]; then - php artisan storage:link - php artisan optimize - fi fi exec docker-php-entrypoint "$@" From 1603e7377b45f62e1d7c9f0fdabf3a8995c7e6ce Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 15 Jun 2024 10:28:45 +0200 Subject: [PATCH 25/31] add cert --- .dockerignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.dockerignore b/.dockerignore index dc5a87529..bbd2117fd 100644 --- a/.dockerignore +++ b/.dockerignore @@ -22,6 +22,7 @@ **/Dockerfile **/Thumbs.db .github/ +cert/ docs/ public/bundles/ tests/ From 6d8a2b59629c8da47624f451ce7b5d95e35c1794 Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 15 Jun 2024 10:29:09 +0200 Subject: [PATCH 26/31] not work with laravel --- frankenphp/conf.d/app.prod.ini | 2 -- 1 file changed, 2 deletions(-) diff --git a/frankenphp/conf.d/app.prod.ini b/frankenphp/conf.d/app.prod.ini index 3bcaa71e4..e69de29bb 100644 --- a/frankenphp/conf.d/app.prod.ini +++ b/frankenphp/conf.d/app.prod.ini @@ -1,2 +0,0 @@ -opcache.preload_user = root -opcache.preload = /app/config/preload.php From f7990609d73e09d79a519086ddbf978c00fe4a74 Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 15 Jun 2024 13:42:00 +0200 Subject: [PATCH 27/31] fix issue with volume when has deleted on dev --- compose.prod.yaml | 7 +++++++ compose.yaml | 4 ---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/compose.prod.yaml b/compose.prod.yaml index d9dcd9db6..f7cc6bbbb 100644 --- a/compose.prod.yaml +++ b/compose.prod.yaml @@ -4,3 +4,10 @@ services: build: context: . target: frankenphp_prod + volumes: + - storage_data:/app/storage + - cache_data:/app/bootstrap/cache + +volumes: + storage_data: + cache_data: diff --git a/compose.yaml b/compose.yaml index 17737938c..d51a91905 100644 --- a/compose.yaml +++ b/compose.yaml @@ -12,8 +12,6 @@ services: volumes: - caddy_data:/data - caddy_config:/config - - storage_data:/app/storage - - cache_data:/app/bootstrap/cache ports: # HTTP - target: 80 @@ -31,5 +29,3 @@ services: volumes: caddy_data: caddy_config: - storage_data: - cache_data: From 3835c430f14db81e99b71fb0f2347d4acbca4a4d Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 15 Jun 2024 13:49:33 +0200 Subject: [PATCH 28/31] setfcal only on prod --- frankenphp/docker-entrypoint.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frankenphp/docker-entrypoint.sh b/frankenphp/docker-entrypoint.sh index 9671c3bf3..9b584a437 100755 --- a/frankenphp/docker-entrypoint.sh +++ b/frankenphp/docker-entrypoint.sh @@ -22,10 +22,12 @@ if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'artisan' ]; then composer run-script post-create-project-cmd fi - setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX storage - setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX storage - setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX bootstrap/cache - setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX bootstrap/cache + if [ "$APP_ENV" = 'production' ]; then + setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX storage + setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX storage + setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX bootstrap/cache + setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX bootstrap/cache + fi fi exec docker-php-entrypoint "$@" From 6237bbfbef2c4e40258fb329ba256726357c52e7 Mon Sep 17 00:00:00 2001 From: Florian <88294294+fouteox@users.noreply.github.com> Date: Sat, 15 Jun 2024 20:10:37 +0200 Subject: [PATCH 29/31] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 654856ce2..774569530 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,8 @@ with [FrankenPHP](https://frankenphp.dev) and [Caddy](https://caddyserver.com/) 6. [TLS Certificates](docs/tls.md) 7. [Using a Makefile](docs/makefile.md) 8. [Troubleshooting](docs/troubleshooting.md) -9. [Updating the template](docs/updating.md) +9. [Use With Vite](docs/vite.md) +10. [Updating the template](docs/updating.md) ## License From 8d3aae5fc6663347f98c897cbde482d0ac843abc Mon Sep 17 00:00:00 2001 From: Florian <88294294+fouteox@users.noreply.github.com> Date: Sat, 15 Jun 2024 20:38:27 +0200 Subject: [PATCH 30/31] Create vite.md --- docs/vite.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 docs/vite.md diff --git a/docs/vite.md b/docs/vite.md new file mode 100644 index 000000000..b9c07c8ee --- /dev/null +++ b/docs/vite.md @@ -0,0 +1,43 @@ +# Vite + +To take advantage of the benefits of Vite, follow the instructions below. + +1. If you haven't already, start the project `docker compose up --pull always -d --wait` +2. Check that the laravel home page appears correctly `https://localhost` +3. Run `docker compose exec php npm install @vitejs/plugin-basic-ssl --save-dev` +4. Update your vite.config.js : +```js +import { defineConfig } from 'vite'; +import laravel from 'laravel-vite-plugin'; ++ import basicSsl from '@vitejs/plugin-basic-ssl' + +export default defineConfig({ ++ server: { ++ https: true, ++ host: '0.0.0.0', ++ hmr: { ++ host: 'localhost', ++ } ++ }, + plugins: [ ++ basicSsl({ ++ /** name of certification */ ++ name: 'WhatYouWant', ++ /** custom trust domains */ ++ domains: ['localhost'], ++ /** custom certification directory (from the project root for example) */ ++ certDir: './cert' ++ }), + laravel({ + input: ['resources/css/app.css', 'resources/js/app.js'], + refresh: true, + }), + ], +}); +``` +5. Just before `` balise on `resources/views/welcome.blade.php`, add this : `@vite(['resources/css/app.css', 'resources/js/app.js'])` +6. Run `docker compose exec php npm run dev` +7. Accept certificate `https://localhost:5173` +8. Enjoy, you have vite refresh : `https://localhost` + +Of course, you can also use it with any starter kit. From f37f2b7819ae873b77708db648f010942396260e Mon Sep 17 00:00:00 2001 From: Florian <88294294+fouteox@users.noreply.github.com> Date: Sat, 15 Jun 2024 20:44:47 +0200 Subject: [PATCH 31/31] Update vite.md --- docs/vite.md | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/docs/vite.md b/docs/vite.md index b9c07c8ee..a6478ac90 100644 --- a/docs/vite.md +++ b/docs/vite.md @@ -2,10 +2,16 @@ To take advantage of the benefits of Vite, follow the instructions below. -1. If you haven't already, start the project `docker compose up --pull always -d --wait` -2. Check that the laravel home page appears correctly `https://localhost` -3. Run `docker compose exec php npm install @vitejs/plugin-basic-ssl --save-dev` -4. Update your vite.config.js : +1. If you haven't already, start the project: +``` +docker compose up --pull always -d --wait +``` +2. Check that the laravel home page appears correctly: [https://localhost](https://localhost) +3. Run: +``` +docker compose exec php npm install @vitejs/plugin-basic-ssl --save-dev +``` +4. Update your vite.config.js: ```js import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; @@ -35,9 +41,15 @@ export default defineConfig({ ], }); ``` -5. Just before `` balise on `resources/views/welcome.blade.php`, add this : `@vite(['resources/css/app.css', 'resources/js/app.js'])` -6. Run `docker compose exec php npm run dev` -7. Accept certificate `https://localhost:5173` -8. Enjoy, you have vite refresh : `https://localhost` +5. Just before `` balise on `resources/views/welcome.blade.php`, add this: +```javascript +@vite(['resources/css/app.css', 'resources/js/app.js']) +``` +6. Run: +``` +docker compose exec php npm run dev +``` +7. Accept certificate: [https://localhost:5173](https://localhost:5173) +8. Enjoy, you have vite refresh: [https://localhost](https://localhost) Of course, you can also use it with any starter kit.