Giter VIP home page Giter VIP logo

dockerfile-laravel's Issues

Support for FilamentPHP

What and Why:
What: Run Filament Cache command when Filament is installed for a Laravel application

Why: Thanks to community post, it was discovered that Laravel apps with Filament installed get really low requests per second( I tested, and got 5 requests per second ). This can be improved by running Filament's cache commands.

How:
Revise Laravel's Dockerfile template to run the Filament cache commands when "filament/filament" is detected in the composer.json file

Related to:
flyctl PR
Community post

Publish as a Package in Packagist.org

We need this package to be installable via composer. This can be done by publishing it in https://packagist.org.
Before publishing please make sure to:

Changes to view files are not reflected in built command

Changes in view files are not included in the built phar file after building changes. Using the storage/framework/views for storing view cache can make these cached views visible, deletable, and once deleted, allow for new changes to be reflected on the built package/application.

Detect Laravel Version

What:
Detect the Laravel Version of a Laravel project.

How:
Check the contents of the composer.json file, or the result of php artisan --version

Why:
We can generate Dockerfile content to accommodate to different Laravel versions

Exceptions only showing up as "unknown error" on fly.io

please let me know if this should rather be posted in the community forum.

If i trigger an exception all i see in the fly logs is: ERROR unknown error

more precisely:
Screenshot 2024-04-23 at 11 57 45

no details about it.
i tested this locally with frankenphp and stderr and did see the exception in frankenphp's log

logging.php

'stderr' => [
    'driver' => 'monolog',
    'level' => env('LOG_LEVEL', 'debug'),
    'handler' => StreamHandler::class,
    'formatter' => env('LOG_STDERR_FORMATTER'),
    'formatter_with' => [
        'includeStacktraces' => true,
    ],
    'with' => [
        'stream' => 'php://stderr',
    ],
    'processors' => [PsrLogMessageProcessor::class],
],

fly.toml

[build]
  [build.args]
    NODE_VERSION = '18'
    PHP_VERSION = '8.3'

[env]
    APP_ENV = 'production'
    LOG_CHANNEL = 'stderr'
    LOG_LEVEL = 'info'
    LOG_STDERR_FORMATTER = 'Monolog\Formatter\JsonFormatter'
    SESSION_DRIVER = 'cookie'
    SESSION_SECURE_COOKIE = 'true'


[http_service]
  internal_port = 8000
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']

[processes]
  app = ""
#  cron = "cron -f"
#  worker = "php artisan queue:listen"

[[vm]]
  size = 'shared-cpu-1x'
  memory = "512MB"

Create a Self-contained Self-executable binary out of the binary built

What:
Create a dockerfile-laravel binary that is standalone, and executable by itself

Why:
There are cases when the dockerfile-laravel package is not installable via composer.
In this cases we would want to download the binary instead.

Right now the phar file created by Laravel Zero relies on the environment it is run on to contain a suitable PHP interpreter.

HOW:
This is why we should try creating a standalone binary of our dockerfile-laravel generator through frankenphp's standalone binary creation

Support for Generating .fly directory from dockerfile-laravel?

Should the .fly directory, which contains the /scripts folder that runs commands for caching, etc, be generated from the dockerfile-laravel command?

No:

  1. The name of the repository is dockerfile-laravel, from the name, it is assumed that the command generates dockerfile-related stuff. Not fly scripts

Yes:

  1. The dockerfile-laravel is already used by flyctl to generate the Dockerfile, it makes sense for it to generate other supporting scripts as well, like those found in the .fly directory
  2. Although the .fly scripts are not Dockerfile variations, these scripts contain startup commands the Dockerfile use for deploying a Laravel app to Fly.io. So since these are used by the Dockerfile( to setup a Laravel app for production ), we can say that these scripts are "deploy-to-fly-production" scripts, hence an indirect part of a Dockerfile the generated.

Detect Octane Flavor

What:
https://flyio.slack.com/archives/C042W39VAMB/p1710787888107569
Detect flavors of octane:

  1. FrankenPHP
    > Presence of frankenphp file in base directory
  2. RoadRunner
    > .rr dir in base directory
    > keywords in composer.json
  3. Swoole
    > This is actually a default option in the dockerfile generatedby flyctl for laravel apps with octane
    maybe
    > Can this be detectable if the swoole extension is available in the current dev environment? So check php.ini?

Why:
https://flyio.slack.com/archives/C042W39VAMB/p1711553910059719?thread_ts=1711549635.827029&cid=C042W39VAMB

TLDR: detectables should be defaultables.

SetUp Github Actions to Run for changes pushed to main

Build a new binary of the package for production when new changes are pushed to the repository.

Also, look at this from packagist:

This package is not auto-updated. Please set up the [GitHub Hook](https://packagist.org/about#how-to-update-packages) for Packagist so that it gets updated whenever you push!

Use an Upstream base image

WHAT AND WHY
Update the generated Dockerfile to use an upstream image, similar to how the current laravel-docker repository is..

There are three primary reasons behind this move:

  1. To remove the scope of having to maintain the custom image built from the laravel-docker repository for SOC2 compliance. This was brought up from a customer request for periodic security patches and maintenance for the custom image we have provided, which we currently cannot fully commit to.
  2. Consistency: The generated Dockerfiles for other frameworks like Rails, Elixir, Javascript, all use upstream images as base. For consistency, we should also follow for the Dockerfile generated for Laravel apps.
  3. Finally, this move will result in depositing config files to the users' project directory where they can visibly and readily find them, providing them full control over these files, as I quote @rubys :

they can rerun dockerfile-laravel when they want to pick up changes, hold back, and even make their own changes to these files."


HOW:
It's simple really! The laravel-docker repository already makes use of a Dockerfile that makes use of an upstream base image. So, we'll just make use of that Dockerfile. Further, since that Dockerfile requires several config file, we'll copy those over to the dockerfile-laravel repository as well.

Basically copy over the laravel-docker logic to dockerfile-laravel. This will result in the same Dockerfile logic, while using an upstream base image instead of the custom one we've provided.


NOTES:

  1. For reference here is the discourse post tackling this issue
  2. To make this a clean move and reduce the number of files to check. I'll create more than one PR to address this issue:
    a. Move the config files required by the laravel-dockerfile over to this repository
    b. Move the Dockerfile logic of laravel-dockerfile over to this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.