Practical HowTo for creating a Vagrant/VirtualBox based development environment.
This environment is dedicated to the program and should not be used 'as is' for writing production code (mainly because off SSH settings for GitHub). Keep in mind that this environment is not permanent and will eventually be destroyed.
First you have to download and install the following software on your machine
- VirtualBox (version > 5.2.18)
- Vagrant (version > 2.1.5)
Test the install:
- Open a
console
and runvagrant -v
. You should see something like:Vagrant 2.1.5
- Open VirtualBox
After the install of
VirtualBox
andVagrant
is complete, you can useVagrant
to install a fully provisioned VM
- Download this repository as a zip file.
click on the green
Clone or Downoload
button and chooseDownload ZIP
as explained here - On your machine, unzip the downloaded file
dev-environment-master.zip
in a convenient folder of your choice (C:\Users\myself\wit\
for example, the name and the location of the folder does not matter) - IMPORTANT: You need to open the
Vagrantfile
with a text editor and provide your GitHub username, the email address you have registered on GitHub, the number of cpus and and amount of RAM you can give to the virtual machine. Then save the fileVagrantfile
. - Open a
console
and navigate to the same folder, where theVagrantfile
is. - then run
vagrant up
... this will take a few minutes.
You can adjust some of the VM's setting in VirtualBox without updating the
Vagrantfile
The Vagrantfile
defines a VM with 2 cores and 2048 Mb of RAM by default. But once your VM is created you can change these settings as long as the VM is stopped (shut down). Be carefull to set values that won't compromise the host machine.
The following settings can be modified like this: open VirtualBox
, select your VM, then press Settings
> System
> and:
Motherboard
if you want to allocate more RAM (drag the cursor and stop before the red zone)Processor
if you want to use more available cores. Use the cursor to give more cores to the VM
In
VirtualBox
, just after provisioning you can press thesee
button (opens as new window). You canstop
andstart
the VM at any time fromVirtualBox
.
You need to go through these few manual steps to complete the install
- Check keyboard mapping. You might need to run the following command in the Guest VM to ajust keyboard mapping:
sudo dpkg-reconfigure keyboard-configuration
- Open web-browser from the task bar and make Chrome your default browser
- Add your public SSH key to GitHub:
xclip
is already installed on your VM. Just run:xclip -sel clip < ~/.ssh/id_rsa.pub
(this will copy the key in your clipboard) And follow these instructions from step 2 - You can test your SSH connection to GitHub like this, from step 1 (no need to follow other links)
-
A
System program problem detected
window pops up in the host, just after starting the VM.It happens that the
display manager
crashes (while resizing the window or switch to full screen). Ubuntu informs the user by prompting a modal window indicatingSystem program problem detected
. Solution: Haven't found yet how to avoidLigthDM
to crash, but you can get rid of the info message. Run following command:sudo rm -rf /var/crash/*
-
Some keys don't map to the keyboard.
Add manually those keys with
xmodmap
command. The Mac keyboard doesn't map the single-quote (aka apostrophe) on Linux (even after configuration withsudo dpkg-reconfigure keyboard-configuration
) You have first to identify some available mappings withxmodmap -pke
(+ eventuel| grep 57
wheren
is the key number 57). The 5th position in the output is the mapped result ofAltGr
+key
.So we add the following to our
.zshrc
to make the combinationAltGr
+n
to produce'
:xmodmap -e "keycode 57 = n N s N apostrophe N n"
Our
lubuntu 18.04
box is hosted on Vagrant Cloud
Installed software on the VM:
- Java 8
- Maven
- Git
- node
- npm
- Gedit
- cUrl
- Visual Studio Code
- Jetbrains toolbox (easy install IntelliJ - later)