Developing using Arch Linux on VirtualBox x86_64 with a systemd-nspawn container
/docs/developers/setup/virtualbox/
Summary of the setup
Note
This setup is for VirtualBox users on x86_64 hardware, such as Intel Macs, Intel Windows PCs, and Intel Linux boxes. It does not work on Apple Silicon.
In brief:
- Download a virtual machine and run it in VirtualBox. It has all the tools you are going to need pre-installed – build tools, git, IDE etc.
- In the virtual machine, run a single script, and you will have a UBOS Mesh site running that’s even pre-configured for debugging.
Easy, right?
Steps in detail
-
Download the this virtual appliance file: http://depot.ubos.net/ubosdev/ubosdev-x86_64-20221122.ova (1.5GB)
-
In VirtualBox, select “File” / “Import Appliance…”
-
Source: “Local File System” and then select the downloaded file. Select “Next”.
-
Select “MAC Address Policy:” “Generate new MAC addresses for all network adapters” and “Import hard drives as VDI”. Select “Finish”.
-
Importing the appliance will take a little bit of time. It will show up in the list of VMs as
ubosdev 1
or such. -
Start the VM.
-
Logon as
ubosdev
, there is no password.root
does not have a password either: we assume that’s safe enough on your computer. If you don’t think so, set one :-) -
Pick a better screen resolution:
- In “Search”, type “Settings” and run it.
- If there’s an error message saying “Oops, something has gone wrong” about Network settings: ignore it, we are not running Network manager.
- Select “Displays” and pick a resolution that makes sense for your computer setup.
- Close the settings app.
-
In “Search”, type “Console” and run it (you get the “Search” by selecting “Activities” in the menu bar).
-
Fix the permissions on the home directory (current bug in the setup):
% sudo chmod 755 ~ubosdev
-
Set up the UBOS development environment by running:
% ubosdev-container setup --channel red --flavor mesh
Use
--flavor mesh
if you plan to do UBOS Mesh development or you aren’t certain.Note the argument specifying the
red
release channel; theyellow
default one does not work yet.This might take 5-30 min, depending on your network, computer and disk speed.
-
Once this command is complete, you can shutdown the VM any time if you like.
Ongoing development work
-
Run your Development VM.
-
Determine which UBOS Linux container to run:
% ubosdev-container list
-
Run your UBOS Linux container:
% ubosdev-container run --name <name>
where
<name>
is one of the names from the list, e.g.ubos-mesh-red
.This gives you console access to the container. You can shut it down with
^]
. -
Access any deployed web app there from your development VM with the name of the container, e.g.
http://ubos-mesh-red/
. Firefox is pre-installed on the VM. -
To edit your code, IDEs
geany
andnetbeans
are pre-installed on your development VM. -
To open up a shell inside your development container, open a new terminal and execute:
% sudo machinectl shell ubosdev@ubos-mesh-red
if
ubos-mesh-red
is the name of your container. -
To build your UBOS Mesh code, run the UBOS Mesh tools inside your development container:
% mesh-clean % mesh-build % mesh-test
-
To debug your UBOS Mesh code, connect with the Netbeans debugger:
This requires that the Java VM was started with the default debugging flag. This flag is set by default in the default Site JSON that’s deployed when you create a container with
--flavor mesh
.- Run NetBeans
- Menu “Debug” / “Attach Debugger”
- Select Debugger: “Java Debugger (JPDA)”
- Select Connector: “Socket Attach (Attaches by socket to other VMs)”
- Host: name of your container, e.g.
ubos-mesh-develop-red
- Port: 7777
-
To shut down your container, in the terminal where you run it, hit
^]
three times in quick succession.