Skip to content

Installing OS-level packages

With UbiOps it is possible to install additional software/APT packages in environments (Docker Images). Every UbiOps base environment uses a ubuntu:20.04 base image, unless specified otherwise. Additional APT packages can be installed by making use of the ubiops.yaml file. This page provides instructions on how to use the file, including details on its structure and the corresponding system actions performed by UbiOps.
Instructions on the YAML syntax can be found on the YAML documentation website.

Windows packages

Windows packages are not supported at the moment.

Structure

The ubiops.yaml file has a specific structure. Items can be removed from the file if they are not needed, but no more items can be added than the ones specified below. The expected structure of the ubiops.yaml file is as follows:

environment_variables:
  - ...
apt:
    keys:
        urls:
          - ...
        items:
          - ...
    sources:
        urls:
          - ...
        items:
          - ...
    packages:
        - ...

The corresponding system actions performed are explained in the following sections.

Environment variables

The environment_variables section is where you define any system environment variables that should be present in your system runtime environment. You can define as many system environment variables as you want, but remember to keep sensitive data like passwords and API keys secure. The corresponding system action performed by UbiOps is:

export MY_ENV_VARIABLE=my_value

Example:

environment_variables:
  - MY_ENV_VARIABLE_1=my_value_1
  - MY_ENV_VARIABLE_2=my_value_2
  - ...

APT keys

The apt.keys section specifies any keys that should be added to the APT keyring before any packages are installed. This is typically used when installing packages from a custom APT repository.

  • urls: List of URLs to download keys from. UbiOps will download the key and add it to the APT keyring
  • items: List of pre-defined keys to be used

The corresponding system action performed by UbiOps is:

apt-key add YOUR_GPG_KEY

Examples:

As an example, the GPG key of the Microsoft package repository will be added in 2 different ways, by using the urls or by using the items tag. Both methods will result to the same:

Urls

apt:
  keys:
    urls:
      - https://packages.microsoft.com/keys/microsoft.asc
This will download the key at https://packages.microsoft.com/keys/microsoft.asc and add the downloaded key to the APT keyring.

Items

You can also manually add a PGP key, by using the items field. The following code block is the result of manually adding the contents of the file found at https://packages.microsoft.com/keys/microsoft.asc:

apt:
  keys:
    items:
      - | # Note the literal style indicator
        -----BEGIN PGP PUBLIC KEY BLOCK-----
        ...
        -----END PGP PUBLIC KEY BLOCK-----

APT sources

The apt.sources section specifies any APT sources that should be added to the APT sources list before any packages are installed. This is typically used when installing packages from a custom APT repository.

  • urls: List of URLs to download sources from. UbiOps will download the source and add it to the APT sources list
  • items: List of pre-defined sources to be used

The corresponding system action performed by UbiOps is:

curl -s "Your APT source url" | tee -a  /etc/apt/sources.list.d/custom.list
echo "Your APT source item" | tee -a  /etc/apt/sources.list.d/custom.list

Examples:

As an example, the Microsoft package repository will be added in 2 different ways, by using the urls or by using the items tag. Both methods will result to the same:

Urls
apt:
  sources:
    urls:
      - https://packages.microsoft.com/config/ubuntu/20.04/prod.list

This will download the source at https://packages.microsoft.com/config/ubuntu/20.04/prod.list and add the downloaded source to the APT sources list.

Items

You can also manually add a source, by using the items field. The following code block is the result of manually adding the contents of the file found at https://packages.microsoft.com/config/ubuntu/20.04/prod.list:

apt:
  sources:
    items:
      - | # Note the literal style indicator
        deb [arch=amd64] https://packages.microsoft.com/ubuntu/20.04/prod focal main

APT packages

The apt.packages section specifies any APT packages that should be installed before the deployment is started.

The corresponding system action performed by UbiOps is:

apt-get -y install --no-install-recommends YOUR_PACKAGES

Examples:

As an example, python3-dev will be installed:

apt:
  packages:
    - python3-dev