X

@OracleIMC Partner Resources & Training: Discover your Modernization options + Reach new potential through Innovation

Development Setup on OCI

Alper Ozisik
Oracle EMEA A&C Cloud Adoption & Implementation Consultant

There are cases your computer is not satisfying for your development. Sometimes to have a fresh start, sometimes to run on Linux from Windows without a VM, sometimes to be close to the target execution environment.

As a developer, you can use Oracle Cloud Infrastructure (OCI) as your development environment. Dynamic Groups and cloning your disk to speedup onboarding of other developers via using Custom Images. Many other scenarios are possible. I will be using latest Ubuntu Image. You can select any number of images that will suit to your need. There are also other Oracle images available such as Oracle Cloud Developer Image and Visual Studio Code Remote Workstation.

Let us begin with setting up this development environment and connect your favorite Integrated Development Environment (IDE) tools such as Eclipse or Visual Studio Code (VScode) using remote ssh. Theia is a web-based IDE very similar to VScode. If you do not like installing VScode on your local, you can setup remote connection to Theia on OCI.

If you are in a workshop and following this guide. Follow the instructions of your instructor, there might be some steps already created for you.

Following steps are covered in this blog:

  1. Create an instance (for development purpose)
  2. Setup VScode
  3. Use VScode to connect to development instance

Setup compute instance

Objectives

  1. Generate SSH keys
  2. Create Compartment
  3. Create Network
  4. Create Compute instances
    1. Create Compute instances
    2. Use custom Image (see the documentation how to create custom image)

Generate SSH keys

If you have created your SSH keys, you might skip this step
Creating SSH Keys for Use with Oracle Cloud Services explains how to create keys in detail. I would recommend the following steps:

  1. Install Git. If you are on Windows, this will also install Git BASH, contains all necessary tools to generate keys. I will refer to Git BASH as bash or terminal. On any other OS, having a git (if you are a developer) is very essential
  2. Open terminal (on Windows use Git BASH)
    This creates a new ssh key, using the provided email as a label. You will be informed and prompted for more information

    Start the ssh-agent in the background
    This will print something like: Add your private key to the ssh- agent:
  3. This command will display your public key. You will be using this while setting up your own compute instance:

Create Compartment

Compartments are good to isolate resources in the OCI. Using a separate compartment for development purpose will be the best approach here. Let us name this compartment as develop. You can have this on your root, as a generic purpose or place within projects or departments compartment.

Create compartment screenshot
While creating network and compute instances you need to select this development compartment.

Create Network

You might use the same network for all this development purpose compute instances. For creating the network, using Virtual Networking Quickstart is good place to start with. You can select VCN with Internet Connectivity option, unless you do not have an IPSec VPN scenario.
VCN Quick Create screenshotMake sure that you are creating in correct compartment.

You might name this VCN as development too.
VCN Basic Information screenshot

Create Compute instances

Creating Compute instance is a straightforward task. Here the most preferable choices for development environment are shown.

  • If you do not have specific requirement, such as GPU, HPC or Bare Metal, select VM shapes.
  • Name instance with your name, e.g., [yourName]-development or [yourName]-[projectName]
  • Make sure you are in correct compartment, e.g., development
  • Change Image and select: Canonical Ubuntu 20.04 (if you have different preference or there is more up-to-date version, you can select that one too)
    • Using image other than Platform Images might result in restricting shapes
  • Select any (suitable) availability domain
    • If you have plans of using Always Free type compute instance, some availability domains may not provide that option
  • Select any suitable shape. If you have plans of using Always Free compute instance, select Specialty and Legacy > [The options are marked as “Always Free Eligible”]. Otherwise, I will recommend using flexible shapes and AMD options are cheaper than Intel. Using more than one OCPU will make the machine more responsive.
  • Check compartment and network. If you do not use a VPN or bastion host, place the machine on Public Subnet for remote access and assign public IP address
  • May change boot volume options as desired
  • If you already have public keys (generating is explained earlier), you may select those keys. If you do not prefer to provide, system can generate that for you. Download and keep safe both private and public keys.

Create and your compute instance will be up and running soon. Public IP address of the machine will be displayed when the instance is ready.
Compute Instance Ready screenshot

Visual Studio Code setup

Download and install VScode. If you are using a Linux computer, some of the Linux distribution marketplaces contains VScode for faster start.
In order to access to a remote workspace over SSH, Remote SSH extension is required. How to use that tool is explained in the extension page (That green area on bottom left of VScode)

Connect to Remote Machine via VScode

  1. Obtain your machine (public) IP Address. Your IP address will be different to what is show in screenshot.
    Obtain Compute Instace IP address
  2. Press to the green button on bottom left of VScode
    Visual Studio Code press remote ssh button
  3. This will open a dialog of options. Select Remote-SSH: Connect to Host
    Remote connect options
  4. If you have hosts configured earlier, those will be shown. Otherwise, you need to add new. For the first time just type in format: [username]@[Host/IP Address], in my case for Ubuntu images, my user name is ubuntu , if you have selected other images your user name might be opc . As the IP address, use the IP obtained from the first step.
    SSH URL
  5. This will automatically use your credentials within SSH folder. Otherwise, you will be asked. If you have followed the steps of generating SSH keys and used them during instance creation, it will automatically use them and you will not be asked. If you have been following your own flow, you might need to select correct credential keys.
  6. VScode is going to install its agents on remote machine. It will prompt you for which kind of operating system that remote usesTarget OS selection
    In my case it was Ubuntu and I have selected Linux.
  7. If this is your first time connecting to that remote, SSH system will be asking to trust to the remote machine. Select continue to proceed.
    Trust remote ssh server
  8. When the remote installation is complete and everything is ready, VScode will display on the green bottom left part SSH: [Your Host/IP].
    Remote SSH connected

Using VScode Terminal on Remote

VScode has built-in terminal support. If the (target) machine has more than one option, you will be asked to select that kind of terminal. For example, on your local Windows machine with Git-Bash installed it will ask you “Command Prompt”, “Power Shell” or “Git-Bash”. In my case, that remote machine Ubuntu has bash as default terminal and this will not be asked.

Open new terminal
On the top menu, select Terminal > New Terminal to create new one. The keyboard shortcut might be different to you.

Terminal Buttons on VScode

Open files in VScode from terminal

VScode installs a small program on the remote machine. This in communication with your local VScode instance. This program is called code same as on your local machine. It does open the files within VScode or navigates the explorer to that folder. You can try an example:

Using code is advised instead of other terminal based editors, such as vi or nano. In a documentation, while using VScode remote terminal replace the command with code.

This code command will not work if you are on a different user, such as root. In that case, continue to use traditional terminal editors as instructed.

Explore remote files and folders

Built-in VScode explorer can be used explore files and folders on the remote machine.

  1. Open Explorer tab
  2. Open Folder (on remote)
    Open Explorer for remote
  3. This will prompt you which folder as workspace folder to be. Select your desired path. This can be a folder, which your project is located. In this case, I will be opening the user home folder. It is OK to start with home folder, however this is not recommended in later stages, since too many files to watch.
    Open folder
  4. After VScode windows being reloaded, you can see the files on remote location
    Explorer opened

Download and upload files

You can download (remote files & folder) and upload (local files & folders) easily with simple UI operations.

In order to download a file or folder, select that on Explorer and right-click. In the opened context menu, select download
Download file
You will be asked where to save.

In order to upload local files, simply drag & drop to the explorer. While dragging make sure that you are hovering on correct folder
Upload

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.