Create a free account to get access to additional free training videos. Enjoy this free video from CraftQuest! Create a free account to get access to additional free training videos. Join the Community
Local Development with Craft Nitro
Installing Craft Nitro on macOS requires Docker, so that means you need to first have Docker Desktop for Mac installed and working.
Installing Craft Nitro on macOS requires Docker, so that means we need first to have Docker Desktop for Mac installed and working. This a free macOS application via the Docker project.
To install Docker Desktop, go to the Docker Desktop page on Docker.com and grab the download for Mac.
Note that the requirements for installing Docker Desktop are that we are running macOS 10.14 or newer. That covers three versions of macOS going back to Mojave.
We also want to be sure we have at least 4 GB of RAM (but ideally more). Docker is RAM-hungry, so if we have an older Mac with 16 GB or less memory, we might see some slowdowns as we use Docker. Every computer is different, and it depends on the demands other applications put on the RAM.
Once the package download is complete, we drag the Docker application to the Applications directory and then launch it.
At this point, Nitro will do everything else for us. One tweak we may want to make is increasing the amount of RAM Docker Desktop is allowed to consume. The default setting might not be enough RAM, so we could have containers exiting if we have several containers running.
With Docker Desktop installed, we can now move to install Nitro. There are two ways to install Nitro: via Brew and directly via a command-line command.
Installing Nitro via Brew is my preferred way to install Nitro because I handle all of my local software via Homebrew. Homebrew is a package manager that installs the software you need on macOS or Linux.
If you already have Homebrew installed, then you can easily install Nitro using:
➜ brew install craftcms/nitro/nitro
We need to make sure we do not run this until we have Docker Desktop installed in the previous step.
Now we can run nitro init
to set up everything and build your Docker environment.
➜ nitro init
The nitro init
command will take some time as Nitro downloads the images and makes them available via Docker Desktop.
Homebrew isn’t the only way to install Nitro. We can also install Nitro from the command line. We will use the bash shell environment and download and run the installer.
➜ bash <(curl -sLS http://installer.getnitro.sh)
After the download is complete, the installer runs and builds the environment. Using this method, we do not have to run nitro init
as you did with the Homebrew installation option.
The next step in the process is to set up a project with Nitro.
If you have problems installing Nitro, check out the manual installation instructions from the Nitro documentation.
Nitro stores project configurations in a YAML file in a hidden directory in the user directory (on macOS). To see the file, list the files in the directory:
➜ ls ~/.nitro
nitro.crt nitro.yaml
The nitro.yaml
file is where Nitro stores the site configurations. Let’s look inside it:
➜ cat ~/.nitro/nitro.yaml
The file has YAML sections for the database, services, and sites. Editing this file, for example, to remove a site, could be done manually and then just run nitro apply
to apply the updated settings to the Nitro Docker setup.
Local Development with Craft Nitro is made up of the following videos: