" How to build a Pharo web application and publish it online with a bash script" by Mike on at tutorial/ephemeric_cloud_bash_script under #ephemericcloud  

How to build a Pharo web application and publish it online with a bash script

Ephemeric cloud is a REST API based cloud solution that allows you to put your Smalltalk application online using a simple bash script. In this article, I'll propose a template for the script which you may modify and use to build and publish your own projects.

Official Pharo download pages offers a Zeroconf bash script which automatically downloads the latest Pharo Image and VM from a repository. With a little effort, we can add to the script routines to build a project and to publish it in Ephemeric cloud.

1 Prerequirements

The script is tested on Linux and Mac OS X; however, I'm sure it can be run on any system which meet the following dependencies:

2 Bash script

Save the contents of the script in a file named build_publish.sh


[ $# -lt 3 ] && { echo 'Usage: build_publish.sh <build_directory> <ephemeric_user_id> <ephemeric_auth_token>' exit 1; }


STARTUP="ZnZincServerAdaptor startOn: 8080. ReadOnlyWebFileBrowser registerAt: '/local' withLocal: '.'"

[ -d "$JOB_NAME" ] && { echo "Directory $JOB_NAME exists"; exit 2; }

mkdir "$JOB_NAME"
cd "$JOB_NAME"

curl http://get.pharo.org/$PHARO+$VM | bash

[ "$?" -ne 0 ] && exit 1

./pharo Pharo.image save "$JOB_NAME" --delete-old

./pharo "$JOB_NAME.image" config $REPO $PROJECT --install=$VERSION
./pharo "$JOB_NAME.image" eval "${STARTUP}. Smalltalk saveSession"

tar -czf "$JOB_NAME.tar.gz" "$JOB_NAME.image"

curl -X POST -F "imageTarGz=@${JOB_NAME}.tar.gz" "https://www.pharocloud.com/api/ephemerics/user/${EPHEMERIC_USER}?auth=${EPHEMERIC_TOKEN}" --progress-bar --verbose

3 How to run

To run the script open a console, change a directory to a catalog where you saved the file build_publish.sh and execute the following command:

bash build_publish.sh webfiledemo ephemeric_user_id ephemeric_auth_token

The building and publishing process may take some time up to 10 minutes. After the process finishes you should see a hostname where the project is published on the last line of the output.



If you did not change the script then it builds and publishes WebFileBrowser project that you may open at /local path of the web site (ex: http://eph-c616c8b3.swarm.pharocloud.com/local)

4 How it works

The script creates a temporary folder in the current directory, downloads a Pharo Image and a VM and installs a project in the Image.

After installation is complete the script starts a web server on 8080 port, performs project initialization and saves the Image.

On the last step script creates an Image Archive (using tar utility) and publishes it in the Ephemeric cloud.

It is possible to add files to the tar archive if they are required for your project to run (ex.: like static resources).

blog comments powered by Disqus