Tuesday, February 11, 2025
HomeJavaTruffleRuby on OCI Container Situations

TruffleRuby on OCI Container Situations


Magnificence at Pace

Ruby is considered one of my favorite programming languages. I actually recognize how expressive it’s, how productive (and the way a lot enjoyable) it makes growth.

Sadly Ruby has a fame for being gradual in comparison with different languages reminiscent of JavaScript.

Whereas the efficiency of the default Ruby interpreter has improved, it nonetheless hasn’t had the engineering funding that goes into V8.

I need to introduce you to an alternate Ruby engine, and a very easy strategy to deploy Ruby functions within the cloud.

TruffleRuby

TruffleRuby is a excessive – efficiency implementation of Ruby, constructed on prime of GraalVM.
GraalVM is a excessive – efficiency, polyglot digital machine.
In benchmark checks, TruffleRuby usually delivers superior efficiency to different Ruby implementations.

You’ll be able to set up TruffleRuby utilizing generally used Ruby managers reminiscent of RVM, chruby && ruby-install, and rbenv.

As soon as you’ve got put in TruffleRuby, you need to use it identical to the usual Ruby engine. Usually I set TruffleRuby as my default runtime.

TruffleRuby is an open-source challenge. GraalVM is developed by way of the open – supply challenge. GraalVM is offered in two flavours:

◉ Neighborhood Version (GraalVM CE) – the open – supply version

◉ Enterprise Version – consists of premium enhancements not included within the open – supply version

OCI Container Situations

Since I like Ruby, it is most likely not a shock that I wish to maintain issues easy.

Primarily you simply create an occasion, specifying the picture you need to use, and the service runs it for you.

So I assumed I would rapidly present you the way you need to use Container Situations to run a easy Sinatra internet utility in a container, with TruffleRuby because the Ruby runtime.

Arms – On

Pre – requisites

◉ OCI account (paid or trial with credit)

◉ VCN with public subnet created

App

The app is in regards to the easiest Sinatra app you may create:

require ‘sinatra’

get “https://oraclejavacertified.blogspot.com/” do

  ‘Hi there world!’

finish

Dockerfile

I’ll use publicly out there GraalVM CE photographs containing TruffleRuby to construct from.

These do not require any license.

I set up some dependencies for constructing native extensions after which the sinatra and skinny gems.

Then copy within the app from above:

FROM ghcr.io/graalvm/truffleruby:newest as construct

RUN dnf set up -y xz patch

RUN gem set up sinatra skinny

FROM ghcr.io/graalvm/truffleruby:slim as runner

COPY –from=construct /choose/truffleruby-22.3.0/lib/gems /choose/truffleruby-22.3.0/lib/gems

COPY myapp.rb .

ENV APP_ENV=manufacturing

EXPOSE 4567

CMD [“ruby”,”myapp.rb”]

Then construct the picture and push it to your repository of selection.

In my case, I’ve chosen to push it to a non-public repository in OCI. For the reason that plan is to deploy to OCI, this is smart, however you possibly can push it to any repository you have got entry to.

In my case the picture is:

oracledeveloper/burton7/truffle:ce

OCI Container Instances, Oracle Java Certification, Oracle Java Prep, Oracle Java Preparation, Java Learning, Java Skills, Java Jobs, Java OCI, Java Learning

Container Occasion

Click on on “Container Situations” after which “Create Container Occasion”:

OCI Container Instances, Oracle Java Certification, Oracle Java Prep, Oracle Java Preparation, Java Learning, Java Skills, Java Jobs, Java OCI, Java Learning

Simply settle for the defaults for the second and click on “Subsequent” (make sure that your subnet is public):

OCI Container Instances, Oracle Java Certification, Oracle Java Prep, Oracle Java Preparation, Java Learning, Java Skills, Java Jobs, Java OCI, Java Learning

Choose your picture and enter your credentials in the event you’re utilizing a non-public repository:

OCI Container Instances, Oracle Java Certification, Oracle Java Prep, Oracle Java Preparation, Java Learning, Java Skills, Java Jobs, Java OCI, Java Learning

Then click on “Subsequent”.

The ultimate display screen ought to look one thing like this:

OCI Container Instances, Oracle Java Certification, Oracle Java Prep, Oracle Java Preparation, Java Learning, Java Skills, Java Jobs, Java OCI, Java Learning

Click on create. It’s best to get a display screen displaying an orange “CI” icon and the message “CREATING”:

OCI Container Instances, Oracle Java Certification, Oracle Java Prep, Oracle Java Preparation, Java Learning, Java Skills, Java Jobs, Java OCI, Java Learning

After a couple of minutes, the icon ought to change to inexperienced, and the general public IP handle of the occasion will likely be displayed:

OCI Container Instances, Oracle Java Certification, Oracle Java Prep, Oracle Java Preparation, Java Learning, Java Skills, Java Jobs, Java OCI, Java Learning

In the event you then open one other tab with the URL http://<public IP>:4567 you must get the normal “Hi there world!” message:

OCI Container Instances, Oracle Java Certification, Oracle Java Prep, Oracle Java Preparation, Java Learning, Java Skills, Java Jobs, Java OCI, Java Learning

Supply: oracle.com

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments