Developing on an Ubuntu Linux workstation
/docs/gears/developer/setup/ubuntu/
Note
DRAFT
Prerequisites
These instructions assume you have a working (physical or virtual) development
system running Ubuntu Linux.
Either an x64_64
or an ARM (aarch64
) system will work.
It is not required, but if you can, run btrfs
as the file system of your home directory.
Its copy-on-write functionality will save you some disk space and some time.
Make sure systemd-nspawn
is installed
Install it with:
% sudo apt install systemd-container
Make sure the ip6_tables
kernel module is loaded
To load it on every reboot:
% sudo bash -c "echo ip6_tables > /etc/modules-load.d/ip6_tables.conf"
% sudo /usr/lib/systemd/systemd-modules-load
Allow the Linux container to reach the internet
Simply run systemd-networkd
in addition to NetworkManager
. Amazingly,
that works and you don’t need to do anything more complicated:
% sudo systemctl enable --now systemd-networkd.service
Install UBOS development tools
-
Create a suitable Python3 venv and activate it, such as with:
% python3 -m venv ~/ubos-venv % . ~/ubos-venv/bin/activate
-
Get the source of
ubos-python-utils
and install it:In a suitable directory, but in the same shell in which you activated the venv:
% git clone https://gitlab.com/ubos/ubos-python.git % cd ubos-python % cd ubos-python-utils/ubos-pytyhon-utils % pip install .
-
Get the source of
ubosdev-container
and install it:In a suitable directory (probabably not where you just ran
pip install
), but in the same shell:% git clone https://gitlab.com/ubos/ubos-tools.git % cd ubos-tools % cd ubosdev-container/ubosdev-container % pip install .
-
Initialize the UBOS development tools by running:
% ubosdev-container setup
This sets up development and downloads a UBOS container image on the
yellow
release channel, which is the recommended channel for development. (You can also setup development on other channels, if you specify--channel green
, for example).This might take 5-30 min, depending on your network, computer and disk speed.
Setting up a container for development
After setup in the previous step, you now create an actual container from the downloaded template. This distinction between images used as templates and images for actual containers allows you to instantiate the same template more than once, such as to separate different development workstreams or to run constellations of UBOS containers against each other.
-
To determine which container templates you currently have available (that depends on the previous step):
% ubosdev-container list-templates
-
Instantiate one of the available templates into a container to be used for development, such as:
% ubosdev-container create --name ubosdev-yellow1 --templatename ubosdev-yellow
Ongoing development work
-
To determine which UBOS Linux containers you have:
% ubosdev-container list
-
Run your UBOS Linux container:
% ubosdev-container run --name <name>
where
<name>
is the name of an available container, e.g.ubosdev-yellow1
.This gives you console access to the container. This command is simply a wrapper around the
systemd-nspawn
command with options that are useful. You could run it directly, too.You shut down the container with 3 quick
^]
s in the primary container console. -
To open up a non-root shell inside your development container, if
ubosdev-yellow1
is the name of your container, open a new terminal and execute:% sudo machinectl shell ubosdev@ubosdev-yellow1
This essentially does the same thing as if you were to log into your container as user
ubosdev
from the console or viassh
, but you don’t need to have any credentials set up. -
When you run the container with
ubosdev-container run
, your home directory on your Ubuntu Linux host will be the same as the home directory of theubosdev
user in the UBOS Linux container. This makes development much simpler because you can edit files either on the host or in the container; they are the same. -
Depending on your networking setup, you may be able to connect to a Site running inside the UBOS Linux development container by using the container’s name as the hostname in the URL. So if one of your running containers is named
ubosdev-yellow
, typinghttp://ubosdev-yellow/
into your browser on the Ubuntu Linux host may talk to the web server in your container.