sail
sail copied to clipboard
Syncing local environments using a `serve` script
Idea:
In my laravel projects which use sail I often add a serve script, which helps with dependency management and setup for local environments.
The serve script does basically the following:
- Copy
.env.exampleto.envif.envdoesn't exist yet - Install needed sail binaries using a temporary docker container if they don't exist
- Build docker container or rebuild docker container if changes to
docker-compose.ymlwere made - Start docker container using
sail up -d --wait - Install node dependencies if they don't exist or
package-lock.jsonoryarn.lockis out of sync - Install composer dependencies if they don't exist or
composer.lockis out of sync - Migrate Database (on fresh installation even with the seed option)
- Run the Vite dev server
There also is a --fresh option for deleting the current env and setting it up again
The script would be published to the root folder and run with ./serve or it could be published to a new bin folder and could be run using bin/serve
Feedback
For now I only submitted the raw scripts for feedback.
- Do you want the scripts
- What should be changed
- etc.
Therefor some things are missing.
What still needs to be done
- Publishing the scripts
- Creating the folder
storage/sailand with a gitignore for determining if the environment are out of sync
Something which could also be done:
- Determine based on the
package-lock.jsonoryarn.lockfile ifnpmandyarnare used, which would result in one less script.