Building Non-Native Language Vessels
Overviewβ
Platform 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.
- 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 Platform
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 Platform
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.
- 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.
- Platform creates a working directory under
/home/shipyard/
- Platform downloads the file you created under the Code section, decompresses it, and begins to run
run.sh
- Platform 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.