Virtual Machine (VM)

The Frontastic Virtual Machine (VM) provides you with a development setup that should work out of the box and gives you a wide range of development tools. That's why we don't ask you to install all the required software on your machine, but we provide an automation to set up a VM which contains everything as close as possible to the other Frontastic environments (Staging and Production).

We're using Vagrant to orchestrate how VMs are set up. By default, we use VirtualBox as the machine provider but it's also possible to use Docker.

To find out more about each of these, take a look at their websites: Vagrant, VirtualBox and Docker. Their documentation and sources like Stack Overflow are really good if you run into any trouble.

Below is a summary of the most important information on our VM Stack. Make sure you've installed locally the list in the previous article before continuing.

First Time Boot

If you're using Windows, open a shell in the checkout of your root directory and execute:

vagrant plugin install vagrant-vbguest

Then execute:

host:frontastic $ vagrant up --provision

All other users can just open a shell in the checkout of your root directory and execute:

host:frontastic $ vagrant up --provision

Vagrant will now run for quite some time performing the following steps:

  1. Download the base-box which contains the operating system and some basic software (for VirtualBox this is a slim Ubuntu image)
  2. Setup SSH connection to the machine and mount the required folders for the setup process
  3. Start the provisioning which is then executed by Ansible inside the VM

This process can take quite some time on its first run. This is because an entire system environment is being installed and several software components are initialized including their dependency managers.

After the provisioning has completed successfully, your machine is ready to go and you should be able to access the developer landing page at [ http://frontastic.io.local/].

Connection and Sync

Always use the below command in an open shell in your checkout directory at the start of your day:

vagrant up --provision [--provider=docker] && vagrant reload

It pulls the latest changes from Git and the --provision flag ensures that everything in the VM is kept up to date and all (new) dependencies will be installed automatically.

For additional information about your project setup, available components, logs and much more please refer to http://frontastic.io.local/.

Working on the Shell

Once the VM is booted, you can access it by executing the below command on the shell in the root of your checkout:

host:frontastic $ vagrant ssh

This brings the shell inside of the machine by SSH and you find yourself as the user vagrant in the mounted checkout of your source code in /var/www/frontastic and where you can use various console commands (we'll come to those later in this section).

All files in the project checkout should be owned by the vagrant user, so you can access them in this state. If you need additional permissions to access system components (e.g. the Syslog) you can use sudo to acquire root permissions without any passwords.

The files in this repository checkout are automatically synchronized to the VM using NFS if you are working on a Unix-like system (e.g. Linux & macOS). On Windows, please configure your IDE accordingly to synchronize files to the Vagrant Machine (e.g. here are instructions for PHPStorm).

Exiting this shell (using the exit command or <Ctrl>+<d>) in the VM just brings you back to your host system as with any other SSH connection.

You may want to access the VM via SSH without using the vagrant ssh command (e.g. because you prefer a GUI client or your IDE supports working with VMs through SSH). You can see the required setting on your shell using:

host:frontastic $ vagrant ssh-config

Halt and Restart

Once you're done with your day or if you need to switch to another project, you need to shutdown the Frontastic VM to save resources. This can be done using:

host:frontastic $ vagrant halt

When this command is finished, the VM is shut down as if you would power-down the computer that it contains.

Vagrant and Suspend/Hibernate/Sleep

Vagrant machines might experience trouble if you leave them running while you put your host machine into sleep mode. We recommend to shut down the VM properly before suspending your host.

If you want to resume work you can simply do:

host:frontastic $ vagrant up

You'll see that the --provision flag was left out in this case. If you perform the up command without this flag, the machine will just be booted and provisioning will not be started again. This is fine when you halt/boot multiple times a day, but we recommend using vagrant up --provision at least once a day to ensure new required software is installed and dependencies are pulled in correctly.

Destroying

It might happen that your VM is damaged or that you stop working on the project and therefore want to get rid of it. Using:

host:frontastic $ vagrant destroy

and confirming that you really want to destroy the VM will do this.

Please note that if you want to achieve an entirely clean state you need to delete your checkout and perform a new clone of the repository. This is due to the fact that provisioning generates files in your checkout (dependencies in node_modules and vendor directories but also environment files) which are not removed during vagrant destroy.


‹ Back to Article List

Next Article ›

Frontasticli (Bodyless Head)

Still need help? Contact Us Contact Us