fly-apps / fly-laravel

Run your Laravel apps on Fly
40 stars 3 forks source link

Dockerfile Generator #54

Open fideloper opened 10 months ago

fideloper commented 10 months ago

Similar to what Sam did for Ruby, I think creating a Dockerfile generator would be interesting.

  1. It's useful for anyone who wants to Dockerize Laravel
  2. There are "flavors" of Docker container that we can allow people to choose from:
    • Nginx + PHP-FPM vs Nginx Unit vs Nginx + Laravel Octane
    • Whether we should build static assets or not (NodeJS build step)
    • PHP Version
    • Node Version
  3. It de-couples flyctl from the Laravel stuff generated

My proposed command would be something like:

./fly dockerize --php 8.2 --node 16 --unit 

Potential flags:

--php=8.2   - (version) Set the PHP version
--node=16   - (version) Set the Node version
--no-static - (bool) Do not build static assets (--node is ignored)
--unit      - (bool) Install container with just Nginx Unit (no Nginx / PHP-FPM)
--fpm       - (bool) Install container with Nginx + PHP-FPM (default)
--octane    - (bool) Install container with Nginx + Octane support (swoole and roadrunner)

These settings could perhaps also be saved to a local .fly.yaml file or similar so when users run fly launch we could pre-populate PHP_VERSION / NODE_VERSION OR those numbers could be hard-coded in the resulting Dockerfile so we don't need to care about those Docker build arguments (currently we have to set Docker build args).

KTanAug21 commented 10 months ago

This would be an awesome addition to the fly-laravel package!

I agree on the settings saved on a .fly.yaml config, it makes the flag config passed by the user visible and findable somewhere( answers the short-term mem-loss question of what did I pass as flag again? Without having to check cmd history ).

Also, we can possibly read from that file as well instead of relying on flags. If there are no flags, we can check that file. If there are flags, override the values in that file?