Building an Image

Building an Image

Starting with Gurobi 8.0, we have greatly simplified the process to create a custom virtual machine image running the Gurobi Remote Services. This will give you more flexibility to start your servers in any Azure data center around the world. Also, you will be able to select and maintain the operating system. At the time of writing this guide, we recommend using the ubuntu 16.04 LTS Image (we will assume such a choice in the following instructions). We do not recommend to use ubuntu 18.04 yet, as the creation of an image in Azure with this specific operating system leads to networking problems. In the following section, we will explain how to create an image using the portal or Packer. Using Packer is recommended.

Building an Image using the Azure Portal

In order to create manually the Image, please follow these steps, you should be very familiar with Azure:

  1. Launch an Azure instance:
    • Login to the Azure portal.
    • Select the Resource groups menu option and click on Add to create a new resource group gurobi.
    • Select the Virtual machines menu options and click on Add to start the creation of a new virtual machine.
    • Select the the ubuntu 16.04 LTS or later base Image and click on create.
    • Then, give the machine a name grbrs9.0.1, set the username to ubuntu and give a password. Set the resource group the gurobi and click on OK.
    • Then, select a small machine type, such as A0 or A1.
    • Then, select the public inbound port SSH(22) to be open, and click on OK.
    • Review the configuration and click on Create.
    • Select the Virtual machines menu option and wait for the instance to be running to lookup the instance public IP (we will call it azure-instance).
  2. Copy the server package to your instance:
    scp gurobi_server9.0.1_linux64.tar.gz ubuntu@azure-instance:/tmp/
  3. Log in to your instance:
    ssh ubuntu@azure-instance
  4. Unpack the server package:
    sudo tar xfz /tmp/gurobi_server9.0.1_linux64.tar.gz -C /opt/
  5. Replace the configuration file with the predefined Azure configuration:
    sudo cp /opt/gurobi_server9.0.1/linux64/bin/grb_rs_azure.cnf /opt/gurobi_server9.0.1/linux64/bin/grb_rs.cnf
    Alternatively, you can copy a configuration file that you prepared in advance.
  6. Review and update the configuration file as necessary (optional):
    sudo vi /opt/gurobi_server9.0.1/linux64/bin/grb_rs.cnf
  7. Start the Remote Services:
    sudo /opt/gurobi_server9.0.1/linux64/bin/grb_rs start
  8. Verify the log. The log messages are automatically forwarded to the syslog and also to service.log rotating file:
    tail -f /opt/gurobi_server9.0.1/linux64/bin/service.log
    The log file should indicate that the server started. Disregard the message about the license being invalid, unless you modified the configuration file with a CLOUDKEY. However, make sure that there is no errors about the configuration file and properties. Here is a sample of the expected output:
    2018-03-01T17:20:46Z - info  : Starting API server (HTTP) on port 80...
  9. Prepare the machine for the image
    sudo waagent -deprovision+user
  10. Log out of the instance
  11. Select the instance in the Azure dashboard and click on Capture. Select the existing resource group gurobi and select the option to delete the VM after creating the image.
  12. Wait for the image to be ready.

Building an Image with Packer

You can easily automate the creation of the Image using Packer. Here is a sample script provided as-is. You can easily extend it to copy a predefined configuration file, or to set up TLS encryption by copying your private key and certificate. With this script example, Packer will also select the latest ubuntu 16.04 base Image for you. To use this script, please follow these steps:

  1. If not done already, you need to create a resource group to store the image. Login to the Azure portal. Select the Resource groups menu option and click on Add to create a new resource group gurobi.
  2. Install Packer
  3. Create a new directory
  4. Download the script gurobi-azure.json and save it in this new directory.
  5. Download the server package gurobi_server9.0.1_linux64.tar.gz and save it in this new directory.
  6. Run Packer from this directory and provide your Azure account information on the command line:
        $ packer build \
  7. When the script is completed, you can get the image name at the end of the log:
    ==> Builds finished. The artifacts of successful builds are:
    --> azure-arm: Azure.ResourceManagement.VMImage:
    ManagedImageResourceGroupName: gurobi
    ManagedImageName: gurobi-server9.0.1-1535730766
    ManagedImageLocation: eastus