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​
For the sake of the this tutorial, we suggest starting off by building a Testing Project. You can follow this tutorial to set that up.
Getting started with this walkthrough is fairly straight-forward.
- Ruby
- Go
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:
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 packageyell
c. Runs the Ruby scriptscript.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 theyell
package
First, download this zipped Go code, named non_native_language_go.zip
to your computer without making any changes.
Feel free to review the code in both run.sh
and script.go
to see what each is doing. Here's a brief overview:
run.sh
: this is the "entrypoint" for our Vessel code since Bash, not Go, is natively supported in Shipyard
a. Initializes Go modules for third-party packages
b. Installs the third-party packagelogrus
c. Runs the Go scriptscript.go
: this is the core of the code and is written entirely in Go
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 thelogrus
package
Steps​
Step 1 - Build a Fleet with a Bash Vessel​
- Click the + New Fleet button on the left sidebar.
- Select either the Playground or Testing Project and then click Select.
- Click the plus icon along the left side of the Fleet Builder sidebar.
- Click on the Bash option under Code Vessels.
Step 2 - Fill Out Details​
- Ruby
- Go
Information Panel​
- Give your Vessel the name of
Non-Native Language - Ruby
.
Code Panel​
- Type
run.sh
into the File to Run field. - In the radio button options, select Upload.
- 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​
- Click the + Add Bash Package button add a new package.
- In the Package Name field, type
ruby-full
.
Information Panel​
- Give your Vessel the name of
Non-Native Language - Go
.
Code Panel​
- Type
run.sh
into the File to Run field. - In the radio button options, select Upload.
- 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_go.zip
file.
Bash Packages Panel​
- Click the + Add Bash Package button add a new package.
- In the Package Name field, type
golang
.
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​
- Click the Run your Fleet button. This will kick off an On Demand trigger and redirect you to the Fleet Log page.
- 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.
- Shipyard creates a working directory under
/home/shipyard/
- Shipyard downloads the file you created under the Code section, decompresses it, and begins to run
run.sh
- Shipyard prints out the text
Top story on Hacker News stats
followed by thetitle
,score
, andlink
values
- Ruby
- Go
You've successfully created and verified a Vessel using a non-native language.