<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>pharo Archives | Clever Cloud</title>
	<atom:link href="https://stagingv6.cleverapps.io/blog/tag/pharo/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>From Code to Product</description>
	<lastBuildDate>Mon, 05 Jan 2015 14:04:00 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2023/03/cropped-cropped-favicon-32x32.png</url>
	<title>pharo Archives | Clever Cloud</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Smalltalk in The Cloud</title>
		<link>https://stagingv6.cleverapps.io/blog/guests/2015/01/05/smalltalk-in-the-cloud/</link>
		
		<dc:creator><![CDATA[Geoffroy Couprie]]></dc:creator>
		<pubDate>Mon, 05 Jan 2015 14:04:00 +0000</pubDate>
				<category><![CDATA[Guests]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[feature]]></category>
		<category><![CDATA[pharo]]></category>
		<category><![CDATA[seaside]]></category>
		<category><![CDATA[smalltalk]]></category>
		<guid isPermaLink="false">https://www2.cleverapps.io/wp/blog/technology/2015/01/05/smalltalk-in-the-cloud/</guid>

					<description><![CDATA[<p><img width="1402" height="544" src="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/smalltalkalpha.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async" fetchpriority="high" srcset="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/smalltalkalpha.png 1402w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/smalltalkalpha-300x116.png 300w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/smalltalkalpha-1024x397.png 1024w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/smalltalkalpha-768x298.png 768w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/smalltalkalpha-1368x531.png 1368w" sizes="(max-width: 1402px) 100vw, 1402px" /></p><p><em><a href="https://twitter.com/gcouprie">Geoffroy Couprie</a> is a consultant in software security and a independant developer. After testing Clever Cloud for a while, he challenged himself trying to run Smalltalk on our PaaS. Here&#39;s the recap of his findings.</em></p>
<p>The Smalltalk world offers a radically different way to create and run software, and I have always loved to tinker with it. Thanks to the recent work around Docker at Clever Cloud, it is now possible to run Pharo Smalltalk apps, even Seaside ones, on this PaaS.</p>
<span id="more-2991"></span>

<h2 id="thinking-in-smalltalk">Thinking in Smalltalk</h2>
<p>One of the most interesting features of Smalltalk is the image, which is a file containing a list of serialized objects. When you start your virtual machine, you load the image. When you stop, you serialise everything: classes, methods, instances of classes, windows, even running web servers. And when you start, you get back your environment in the same state. Even writing code is different: you are not editing a file, you are editing the implementation of a method, serialised like everything else in the image. That way, you can modify code while it is running easily.</p>
<a class="image-popup-no-margins" href="https://www2.cleverapps.io/app/uploads/2021/08/explorer.png" alt="Feeling at home in the Pharo world">
  <img src="https://www2.cleverapps.io/app/uploads/2021/08/explorer.png">
</a>

<p>The traditional method for deploying a web server consists in preparing the image with the code, and uploading the whole image on the server. This is at odds with deployment process at Clever Cloud, based on a simple Git push. So it requires a few steps.</p>
<h2 id="docker">Docker</h2>
<p>Thanks to the recent developments around Docker support, it is now possible to run any language or platform on these servers. So I prepared two images, one to <a href="https://registry.hub.docker.com/u/geal/archlinux-pharo-smalltalk/">install Pharo Smalltalk on an archlinux Docker container</a>, and the other, based on the first, to <a href="https://registry.hub.docker.com/u/geal/archlinux-seaside/">install the Seaside web framework</a>.</p>
<p>There is nothing tricky in the first image, except needing to install <code>lib32-zlib</code>, <code>lib32-ncurses</code> and <code>lib32-bzip2</code> to run the 32 bits VM on a 64 bits CPU.</p>
<p>The second image runs <a href="https://github.com/Geal/archlinux-pharo-image/blob/master/seaside/install-seaside.st">a .st file</a> to download Seaside, remove default Seaside apps and deactivate the debug bar:</p>
<pre><code class="language-smalltalk">Gofer new
url:&#39;http://www.smalltalkhub.com/mc/Seaside/MetacelloConfigurations/main&#39;;
package: &#39;ConfigurationOfSeaside3&#39;;
load.
((Smalltalk at: #ConfigurationOfSeaside3) project version: #stable) load.

WAAdmin applicationDefaults removeParent: WADevelopmentConfiguration instance.
WADispatcher default handlers keys do:[:name | WAAdmin unregister:name].
Smalltalk snapshot: true andQuit: true.
</code></pre>
<p>Now, we have an image ready for  deployment, and usable for all the future Seaside projects.</p>
<h2 id="preparing-the-code-for-deployment">Preparing the code for deployment</h2>
<p>We could save the image in a git repository, and push the whole file to Clever Cloud, but that would be too easy. What if we could send just the required code through git? Here comes <a href="https://github.com/dalehenrich/filetree">FileTree</a>, a library pre-installed in Pharo, that you can use to export code from the image and add it to a Git repository.</p>
<p>First, let&#39;s get some code to deploy. I will spare you the details, just get the <a href="http://book.seaside.st/book/getting-started/pharo/first-component">WebCounter example from the Seaside book</a>, it is doable under 10 minutes.</p>
<p>Done? Alright. Choose a folder that will contain the code you will push to the server, and <code>git init</code> in that folder. Now open the Monticello browser, add a new repository, select &quot;filetree://&quot; then choose your git folder.</p>
<a class="image-popup-no-margins" href="https://www2.cleverapps.io/app/uploads/2021/08/filetree.png" alt="FileTree">
  <img src="https://www2.cleverapps.io/app/uploads/2021/08/filetree.png">
</a>

<p>Now select your WebCounter package in the Monticello browser, and save the code.</p>
<a class="image-popup-no-margins" href="https://www2.cleverapps.io/app/uploads/2021/08/monticello-save.png" alt="Monticello">
  <img src="https://www2.cleverapps.io/app/uploads/2021/08/monticello-save.png">
</a>

<p>It should now appear in file form in the git folder:</p>
<pre><code class="language-bash">$ tree .
.
└── WebCounter.package
    ├── WebCounter.class
    │   ├── README.md
    │   ├── instance
    │   │   ├── decrease.st
    │   │   ├── increase.st
    │   │   ├── initialize.st
    │   │   └── renderContentOn..st
    │   ├── methodProperties.json
    │   └── properties.json
    ├── monticello.meta
    │   ├── categories.st
    │   ├── initializers.st
    │   ├── package
    │   └── version
    └── properties.json
</code></pre>
<h2 id="loading-the-code">Loading the code</h2>
<p>Now that we have an export of the Seaside component, we will create a Docker image to load the code. First, we need a small script to give the virtual machine at startup, to load the code and run it:</p>
<pre><code class="language-smalltalk">&quot;this uses FileTree to load back the code from the /home/deploy folder&quot;
(MCFileTreeRepository new directory: &#39;/home/deploy&#39; asFileReference) packageDescriptionsFromReadableFileNames  do:
  [:name || version |
  version := (MCFileTreeRepository new directory: &#39;/home/deploy&#39; asFileReference) versionFromFileNamed: name first, &#39;.package&#39;.
  [version load ]
        on: MCMergeOrLoadWarning
        do: [ :ex | [ ex load  ] on: MCNoChangesException do: [] ] ].

FileStream stdout nextPutAll: &#39;WebCounter installed&#39;; lf.

&quot;the Clever Cloud platform expects the app to listen on the 8080 port&quot;
ZnZincServerAdaptor startOn: 8080.

&quot;Register the code we just loaded on the /webcounter address&quot;
WAAdmin register: WebCounter asApplicationAt: &#39;webcounter&#39;.
</code></pre>
<p>Save that code as seaside.st, then we will create the Dockerfile to make it work on the server:</p>
<pre><code class="language-apache"># -*- sh -*-
FROM geal/archlinux-seaside
MAINTAINER Geoffroy Couprie, contact@geoffroycouprie.com

ADD . /home/deploy

EXPOSE 8080

CMD ./pharo Pharo.image ./deploy/seaside.st
</code></pre>
<p>It reuses the archlinux-seaside image I prepared previously, copies the code from the repository in <code>/home/deploy</code>, then starts the image with the code loading script.</p>
<p>With this, you can build and run the image to test it:</p>
<pre><code class="language-bash">$ docker build -t &quot;geal/seaside-example&quot; .
$ docker run -t -i -p 8080:8080 geal/seaside-example /bin/bash
[root@8e726df1bf4e home]# ./pharo Pharo.image ./deploy/seaside.st

UndefinedObject&gt;&gt;DoIt (WebCounter is Undeclared)
WebCounter installed
</code></pre>
<p>If you are on Linux, the website will be available on <a href="http://localhost:8080/webcounter">http://localhost:8080/webcounter</a>. If you use OS X, run <code>boot2docker ip</code>, then access the server at <code>http://&lt;virtual machine IP&gt;:8080/webcounter</code>.</p>
<h1 id="creating-the-app-on-clever-cloud-and-deploying">Creating the app on Clever Cloud and deploying</h1>
<p>Go to <a href="https://console.clever-cloud.com">https://console.clever-cloud.com</a>, create a new application of type Docker, then get the git URL for your app, and do in your repository:</p>
<pre><code class="language-bash">$ git remote add clever git+ssh://git@push.par.clever-cloud.com/&lt;your app id&gt;.git
$ git push clever master
</code></pre>
<p>And that&#39;s it! You can now access the Seaside component at <code>http://&lt;your_app_id&gt;.cleverapps.io/webcounter</code>.</p>
<p>At each new version of the code, export it to Git then push again, and the platform will redeploy everything automatically, rebuilding the Docker containers and the Pharo images. Now, you just need to add a few components to store state, like a database or S3 component, and you are good to go!</p>
<p>All the code is available on Github if you need to play with it:</p>
<ul>
<li><a href="https://github.com/Geal/archlinux-pharo-image">Archlinux Docker images</a></li>
<li><a href="https://github.com/Geal/pharo-seaside-docker-example">WebCounter loaded with Docker</a>, also contains an example for a web application using the Zinc server directly</li>
<li>The example is currently running at <a href="http://pharo-seaside.cleverapps.io/webcounter">http://pharo-seaside.cleverapps.io/webcounter</a></li>
</ul>
<a class="image-popup-no-margins" href="https://www2.cleverapps.io/app/uploads/2021/08/pharo.png" alt="Welcome to Pharo!">
  <img src="https://www2.cleverapps.io/app/uploads/2021/08/pharo.png">
</a>
]]></description>
										<content:encoded><![CDATA[<p><img width="1402" height="544" src="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/smalltalkalpha.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async" srcset="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/smalltalkalpha.png 1402w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/smalltalkalpha-300x116.png 300w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/smalltalkalpha-1024x397.png 1024w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/smalltalkalpha-768x298.png 768w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/smalltalkalpha-1368x531.png 1368w" sizes="(max-width: 1402px) 100vw, 1402px" /></p><p><em><a href="https://twitter.com/gcouprie">Geoffroy Couprie</a> is a consultant in software security and a independant developer. After testing Clever Cloud for a while, he challenged himself trying to run Smalltalk on our PaaS. Here&#39;s the recap of his findings.</em></p>
<p>The Smalltalk world offers a radically different way to create and run software, and I have always loved to tinker with it. Thanks to the recent work around Docker at Clever Cloud, it is now possible to run Pharo Smalltalk apps, even Seaside ones, on this PaaS.</p>
<span id="more-2991"></span>

<h2 id="thinking-in-smalltalk">Thinking in Smalltalk</h2>
<p>One of the most interesting features of Smalltalk is the image, which is a file containing a list of serialized objects. When you start your virtual machine, you load the image. When you stop, you serialise everything: classes, methods, instances of classes, windows, even running web servers. And when you start, you get back your environment in the same state. Even writing code is different: you are not editing a file, you are editing the implementation of a method, serialised like everything else in the image. That way, you can modify code while it is running easily.</p>
<a class="image-popup-no-margins" href="https://www2.cleverapps.io/app/uploads/2021/08/explorer.png" alt="Feeling at home in the Pharo world">
  <img src="https://www2.cleverapps.io/app/uploads/2021/08/explorer.png">
</a>

<p>The traditional method for deploying a web server consists in preparing the image with the code, and uploading the whole image on the server. This is at odds with deployment process at Clever Cloud, based on a simple Git push. So it requires a few steps.</p>
<h2 id="docker">Docker</h2>
<p>Thanks to the recent developments around Docker support, it is now possible to run any language or platform on these servers. So I prepared two images, one to <a href="https://registry.hub.docker.com/u/geal/archlinux-pharo-smalltalk/">install Pharo Smalltalk on an archlinux Docker container</a>, and the other, based on the first, to <a href="https://registry.hub.docker.com/u/geal/archlinux-seaside/">install the Seaside web framework</a>.</p>
<p>There is nothing tricky in the first image, except needing to install <code>lib32-zlib</code>, <code>lib32-ncurses</code> and <code>lib32-bzip2</code> to run the 32 bits VM on a 64 bits CPU.</p>
<p>The second image runs <a href="https://github.com/Geal/archlinux-pharo-image/blob/master/seaside/install-seaside.st">a .st file</a> to download Seaside, remove default Seaside apps and deactivate the debug bar:</p>
<pre><code class="language-smalltalk">Gofer new
url:&#39;http://www.smalltalkhub.com/mc/Seaside/MetacelloConfigurations/main&#39;;
package: &#39;ConfigurationOfSeaside3&#39;;
load.
((Smalltalk at: #ConfigurationOfSeaside3) project version: #stable) load.

WAAdmin applicationDefaults removeParent: WADevelopmentConfiguration instance.
WADispatcher default handlers keys do:[:name | WAAdmin unregister:name].
Smalltalk snapshot: true andQuit: true.
</code></pre>
<p>Now, we have an image ready for  deployment, and usable for all the future Seaside projects.</p>
<h2 id="preparing-the-code-for-deployment">Preparing the code for deployment</h2>
<p>We could save the image in a git repository, and push the whole file to Clever Cloud, but that would be too easy. What if we could send just the required code through git? Here comes <a href="https://github.com/dalehenrich/filetree">FileTree</a>, a library pre-installed in Pharo, that you can use to export code from the image and add it to a Git repository.</p>
<p>First, let&#39;s get some code to deploy. I will spare you the details, just get the <a href="http://book.seaside.st/book/getting-started/pharo/first-component">WebCounter example from the Seaside book</a>, it is doable under 10 minutes.</p>
<p>Done? Alright. Choose a folder that will contain the code you will push to the server, and <code>git init</code> in that folder. Now open the Monticello browser, add a new repository, select &quot;filetree://&quot; then choose your git folder.</p>
<a class="image-popup-no-margins" href="https://www2.cleverapps.io/app/uploads/2021/08/filetree.png" alt="FileTree">
  <img src="https://www2.cleverapps.io/app/uploads/2021/08/filetree.png">
</a>

<p>Now select your WebCounter package in the Monticello browser, and save the code.</p>
<a class="image-popup-no-margins" href="https://www2.cleverapps.io/app/uploads/2021/08/monticello-save.png" alt="Monticello">
  <img src="https://www2.cleverapps.io/app/uploads/2021/08/monticello-save.png">
</a>

<p>It should now appear in file form in the git folder:</p>
<pre><code class="language-bash">$ tree .
.
└── WebCounter.package
    ├── WebCounter.class
    │   ├── README.md
    │   ├── instance
    │   │   ├── decrease.st
    │   │   ├── increase.st
    │   │   ├── initialize.st
    │   │   └── renderContentOn..st
    │   ├── methodProperties.json
    │   └── properties.json
    ├── monticello.meta
    │   ├── categories.st
    │   ├── initializers.st
    │   ├── package
    │   └── version
    └── properties.json
</code></pre>
<h2 id="loading-the-code">Loading the code</h2>
<p>Now that we have an export of the Seaside component, we will create a Docker image to load the code. First, we need a small script to give the virtual machine at startup, to load the code and run it:</p>
<pre><code class="language-smalltalk">&quot;this uses FileTree to load back the code from the /home/deploy folder&quot;
(MCFileTreeRepository new directory: &#39;/home/deploy&#39; asFileReference) packageDescriptionsFromReadableFileNames  do:
  [:name || version |
  version := (MCFileTreeRepository new directory: &#39;/home/deploy&#39; asFileReference) versionFromFileNamed: name first, &#39;.package&#39;.
  [version load ]
        on: MCMergeOrLoadWarning
        do: [ :ex | [ ex load  ] on: MCNoChangesException do: [] ] ].

FileStream stdout nextPutAll: &#39;WebCounter installed&#39;; lf.

&quot;the Clever Cloud platform expects the app to listen on the 8080 port&quot;
ZnZincServerAdaptor startOn: 8080.

&quot;Register the code we just loaded on the /webcounter address&quot;
WAAdmin register: WebCounter asApplicationAt: &#39;webcounter&#39;.
</code></pre>
<p>Save that code as seaside.st, then we will create the Dockerfile to make it work on the server:</p>
<pre><code class="language-apache"># -*- sh -*-
FROM geal/archlinux-seaside
MAINTAINER Geoffroy Couprie, contact@geoffroycouprie.com

ADD . /home/deploy

EXPOSE 8080

CMD ./pharo Pharo.image ./deploy/seaside.st
</code></pre>
<p>It reuses the archlinux-seaside image I prepared previously, copies the code from the repository in <code>/home/deploy</code>, then starts the image with the code loading script.</p>
<p>With this, you can build and run the image to test it:</p>
<pre><code class="language-bash">$ docker build -t &quot;geal/seaside-example&quot; .
$ docker run -t -i -p 8080:8080 geal/seaside-example /bin/bash
[root@8e726df1bf4e home]# ./pharo Pharo.image ./deploy/seaside.st

UndefinedObject&gt;&gt;DoIt (WebCounter is Undeclared)
WebCounter installed
</code></pre>
<p>If you are on Linux, the website will be available on <a href="http://localhost:8080/webcounter">http://localhost:8080/webcounter</a>. If you use OS X, run <code>boot2docker ip</code>, then access the server at <code>http://&lt;virtual machine IP&gt;:8080/webcounter</code>.</p>
<h1 id="creating-the-app-on-clever-cloud-and-deploying">Creating the app on Clever Cloud and deploying</h1>
<p>Go to <a href="https://console.clever-cloud.com">https://console.clever-cloud.com</a>, create a new application of type Docker, then get the git URL for your app, and do in your repository:</p>
<pre><code class="language-bash">$ git remote add clever git+ssh://git@push.par.clever-cloud.com/&lt;your app id&gt;.git
$ git push clever master
</code></pre>
<p>And that&#39;s it! You can now access the Seaside component at <code>http://&lt;your_app_id&gt;.cleverapps.io/webcounter</code>.</p>
<p>At each new version of the code, export it to Git then push again, and the platform will redeploy everything automatically, rebuilding the Docker containers and the Pharo images. Now, you just need to add a few components to store state, like a database or S3 component, and you are good to go!</p>
<p>All the code is available on Github if you need to play with it:</p>
<ul>
<li><a href="https://github.com/Geal/archlinux-pharo-image">Archlinux Docker images</a></li>
<li><a href="https://github.com/Geal/pharo-seaside-docker-example">WebCounter loaded with Docker</a>, also contains an example for a web application using the Zinc server directly</li>
<li>The example is currently running at <a href="http://pharo-seaside.cleverapps.io/webcounter">http://pharo-seaside.cleverapps.io/webcounter</a></li>
</ul>
<a class="image-popup-no-margins" href="https://www2.cleverapps.io/app/uploads/2021/08/pharo.png" alt="Welcome to Pharo!">
  <img src="https://www2.cleverapps.io/app/uploads/2021/08/pharo.png">
</a>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
