sail icon indicating copy to clipboard operation
sail copied to clipboard

Syncing local environments using a `serve` script

Open Jubeki opened this issue 3 years ago • 0 comments

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:

  1. Copy .env.example to .env if .env doesn't exist yet
  2. Install needed sail binaries using a temporary docker container if they don't exist
  3. Build docker container or rebuild docker container if changes to docker-compose.yml were made
  4. Start docker container using sail up -d --wait
  5. Install node dependencies if they don't exist or package-lock.json or yarn.lock is out of sync
  6. Install composer dependencies if they don't exist or composer.lock is out of sync
  7. Migrate Database (on fresh installation even with the seed option)
  8. 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/sail and with a gitignore for determining if the environment are out of sync

Something which could also be done:

  • Determine based on the package-lock.json or yarn.lock file if npm and yarn are used, which would result in one less script.

Jubeki avatar Aug 24 '22 17:08 Jubeki