Customizing the Build

One of the primary reasons to use Laravel Settler is to create a customized version of the Homestead box. You can modify the build process to add, remove, or change software versions.

There are two main ways to customize your build: using the built-in feature flags and by directly editing the provisioning scripts.

1. Using Build Flags

The easiest way to create a lighter-weight box is to use the SKIP_* variables located at the top of the scripts/amd64.sh and scripts/arm.sh files.

# scripts/amd64.sh

SKIP_PHP=false
SKIP_MYSQL=false
SKIP_MARIADB=true
SKIP_POSTGRESQL=false

To disable a feature, simply change its value from false to true before running the packer build command.

  • SKIP_PHP=true: Skips the installation of all PHP versions, Composer, Nginx, and Apache. This is useful if you are building a box for non-PHP projects.
  • SKIP_MYSQL=true: Skips the installation of the MySQL 8 server. The mysql-client package will still be installed for connectivity.
  • SKIP_MARIADB=false: By default, MariaDB is skipped. If you set SKIP_MYSQL=true and SKIP_MARIADB=false, the build process will remove MySQL and install MariaDB instead.
  • SKIP_POSTGRESQL=true: Skips the installation of the PostgreSQL server.

Example: Building a Node.js-Only Box

To build a box focused on Node.js development without PHP or databases, you would edit the script as follows:

SKIP_PHP=true
SKIP_MYSQL=true
SKIP_MARIADB=true
SKIP_POSTGRESQL=true

Then, proceed with the build steps as usual.

2. Modifying Packer Variables

The bin/link-to-bento.sh script automatically increases the virtual disk size by modifying Bento's pkr-variables.pkr.hcl file.

# bin/link-to-bento.sh
# ...
# Set disk_size
sed -i 's/65536/524288/' ../bento/packer_templates/pkr-variables.pkr.hcl

You can manually edit this sed command in the link script to change the disk size to your desired value (in megabytes) before running it.

3. Editing Provisioning Scripts

For more advanced customizations, you can directly edit the provisioning scripts (scripts/amd64.sh or scripts/arm.sh).

This approach gives you complete control over the build. Common modifications include:

  • Changing Software Versions: Modify apt-get install commands to specify a different version of a package.
  • Adding New Software: Add apt-get install, curl, or wget commands to install tools not included in the default build.
  • Modifying Configurations: Change the sed commands that modify .ini or .conf files to adjust settings like memory limits, user permissions, or service ports.
  • Adding Global Packages: Add new composer global require or npm install -g commands to pre-install your favorite tools.

When editing these scripts, remember that they are executed as the root user within the virtual machine during the Packer build process.