Skip to Content

I’m a big Perl fan. My first test application in the Cloud Foundry in the SAP Cloud Platform was thus a Perl application. In this article, I show you how easy Cloud Foundry in the SAP Cloud Platform is and how fast you can publish applications on the Internet.

All you need is a free trial account and 10 minutes time.

Cloud Foundry 101

Cloud Foundry, which is fully supported on SAP Cloud Platform, is a platform as a service (PaaS). This requires a slightly different mindset than the one used for managing a full server. In Cloud Foundry you have aplications which run with the support of buildpacks and services which your code can use. In the case of Cloud Foundry, you manage the platform with a command line tool called cf.

CF Installation

Download and install Cloud Foundry Command Line Interface (cf CLI) for your operating system: http://docs.cloudfoundry.org/cf-cli/

Login

Open the command line and type: cf login

The API endpoint can be found in the Cloud Cockpit.

nils@imac5k ~ $ cf login

API endpoint> https://api.cf.eu10.hana.ondemand.com

Email> nils.knieling@█████

Password>
Authenticating...
OK

Targeted org S0009028968trial_trial

Targeted space dev



API endpoint:   https://api.cf.eu10.hana.ondemand.com (API version: 2.92.0)
User:           nils.knieling@█████
Org:            S0009028968trial_trial
Space:          dev

 

Buildpack

Next we need a buildpack. We use Tobias Oetiker’s Generic Build Pack for Cloud Foundry: https://github.com/oetiker/sourcey-buildpack

Type git clone https://github.com/oetiker/sourcey-buildpack.git and go to the folder with the sample application perl-dancer2.

nils@imac5k $ git clone https://github.com/oetiker/sourcey-buildpack.git

nils@imac5k $ cd sourcey-buildpack/example/perl-dancer2/

 

Deploy

Type cf push. It takes something until everything has been built.

nils@imac5k perl-dancer2 $ cf push
Using manifest file /Users/nils/Projekte/github/sourcey-buildpack/example/perl-dancer2/manifest.yml

Creating app example-perl-dancer2 in org S0009028968trial_trial / space dev as nils.knieling@█████...
OK

Creating route example-perl-dancer2-greedy-holdup.cfapps.eu10.hana.ondemand.com...
OK

Binding example-perl-dancer2-greedy-holdup.cfapps.eu10.hana.ondemand.com to example-perl-dancer2...
OK

Uploading example-perl-dancer2...
Uploading app files from: /Users/nils/Projekte/github/sourcey-buildpack/example/perl-dancer2
Uploading 5K, 8 files
Done uploading
OK

Starting app example-perl-dancer2 in org S0009028968trial_trial / space dev as nils.knieling@█████...
Creating container
Successfully created container
Downloading app package...
Downloaded app package (4.7K)
Staging...
       Environment
       -  WORK_DIR=/home/vcap/tmp/sourcey.51
       -  BUILD_DIR=/tmp/app
       -  APP_DIR=app
       -  PREFIX=/home/vcap/app/sourcey
       -  CACHE_DIR=/tmp/cache/final
       Downloading Perl 5.24.0
       Configuring Perl 5.24.0
       Building Perl 5.24.0
       Installing Perl 5.24.0
       Downloading cpanminus
       Successfully installed Dancer2-0.205001
       89 distributions installed
       Moving binaries to /tmp/app ready for uploading
       Saveing a copy of your binaries to /tmp/cache/final for future use
Uploading droplet, build artifacts cache...
Exit status 0
Staging complete
Uploading build artifacts cache...
Uploading droplet...
Uploaded build artifacts cache (14.8M)
Uploaded droplet (14.8M)
Uploading complete
Stopping instance cf03acbd-2428-499f-8699-b1e817d960c3
Destroying container
Successfully destroyed container

1 of 1 instances running

App started


OK

App example-perl-dancer2 was started using this command `PATH=$HOME/sourcey/bin:$PATH ./SourceyStart.sh`

Showing health and status for app example-perl-dancer2 in org S0009028968trial_trial / space dev as nils.knieling@█████...
OK

requested state: started
instances: 1/1
usage: 256M x 1 instances
urls: example-perl-dancer2-greedy-holdup.cfapps.eu10.hana.ondemand.com
last uploaded: Sat Sep 2 17:24:37 UTC 2017
stack: cflinuxfs2
buildpack: https://github.com/oetiker/sourcey-buildpack

     state     since                    cpu    memory      disk      details
#0   running   2017-09-02 07:30:00 PM   0.0%   0 of 256M   0 of 1G

 

Done 😎

Finished. The application can be opened. The URL can be found in the output of cf push or in the Cloud Cockpit.

 

And one more thing…

How about SSH access? No problem.

Type cf enable-ssh example-perl-dancer2 and cf ssh example-perl-dancer2.

 

nils@imac5k perl-dancer2 $ cf enable-ssh example-perl-dancer2
Enabling ssh support for 'example-perl-dancer2'...

OK
nils@imac5k perl-dancer2 $ cf ssh example-perl-dancer2

vcap@384c2d4a-60dc-417c-7fa5-f257:~$ uname -a
Linux 384c2d4a-60dc-417c-7fa5-f257 4.4.0-83-generic #106~14.04.1-Ubuntu SMP Mon Jun 26 18:10:19 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

vcap@384c2d4a-60dc-417c-7fa5-f257:~$ /home/vcap/app/sourcey/bin/perl -v

This is perl 5, version 24, subversion 0 (v5.24.0) built for x86_64-linux-thread-multi

Copyright 1987-2016, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

 

I wish you a lot of fun with Cloud Foundry in SAP Cloud Platform 👍

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply