Skip to main content

Building Non-Native Language Vessels

Overview​

Shipyard provides indirect support for languages outside of those natively supported (Bash, Python, and Node). This is done by using Bash Vessels to install the given language and any external packages before running the specified command to execute the script. With this approach, the user can effectively use whatever language they choose in Vessel construction.

Note that this approach will likely add in some additional execution time for the Vessel due to the installation and setup going into each Vessel run.

In this walk through, you'll construct a Vessel using a language not natively supported in the platform.

By the end of the tutorial, you'll be able to:

  • Set up a Vessel
  • Use a non-natively supported language for the code
  • Install third-party packages in that language
  • Fetch data from an external API
  • See output in the Logs

Setup​

Getting started with this walkthrough is fairly straight-forward.

First, download this zipped Ruby code, named non_native_language_ruby.zip to your computer without making any changes.

Feel free to review the code in both run.sh and script.rb to see what each is doing. Here's a brief overview:

  1. run.sh: this is the "entrypoint" for our Vessel code since Bash, not Ruby, is natively supported in Shipyard
    a. Updates an environment variable (to suppress a warning in the logs)
    b. Installs the third-party package yell
    c. Runs the Ruby script
  2. script.rb: this is the core of the code and is written entirely in Ruby
    a. Fetches the top stories from the Hacker News API
    b. Gets an ID from the top stories response data
    c. Fetches the story by the ID
    d. Prints information using the yell package

Steps​

Step 1 - Build a Fleet with a Bash Vessel​

  1. Click the + New Fleet button on the left sidebar.
  2. Click the plus icon along the left side of the Fleet Builder sidebar.
  3. Click on the Bash option under Code Vessels.

Step 2 - Fill Out Details​

Information Panel​

  1. Give your Vessel the name of Non-Native Language - Ruby.

Code Panel​

  1. Type run.sh into the File to Run field.
  2. In the radio button options, select Upload.
  3. Click on the grey square with the text "Click or drag file to this area to upload" and upload the previously downloaded non_native_language_ruby.zip file.

Bash Packages Panel​

  1. Click the + Add Bash Package button add a new package.
  2. In the Package Name field, type ruby-full.

Once all of the above information has been filled in, click the Save & Finish button at the bottom of the screen.

Step 3 - Run the Fleet​

  1. Click the Run your Fleet button. This will kick off an On Demand trigger and redirect you to the Fleet Log page.

  1. Click into the Vessel Log by clicking the gantt chart or clicking the Vessel Log ID in the table.

You should see the following page that shows you all of the details about the specific Log.

In the output, you'll see several things.

  1. Shipyard creates a working directory under /home/shipyard/
  2. Shipyard downloads the file you created under the Code section, decompresses it, and begins to run run.sh
  3. Shipyard prints out the text Top story on Hacker News stats followed by the title, score, and link values

success

You've successfully created and verified a Vessel using a non-native language.