<?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>deno Archives | Clever Cloud</title>
	<atom:link href="https://stagingv6.cleverapps.io/blog/tag/deno/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>From Code to Product</description>
	<lastBuildDate>Tue, 19 May 2020 14:00: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>deno Archives | Clever Cloud</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to deploy a Deno application</title>
		<link>https://stagingv6.cleverapps.io/blog/engineering/2020/05/19/deploy-deno/</link>
		
		<dc:creator><![CDATA[Laurent Doguin]]></dc:creator>
		<pubDate>Tue, 19 May 2020 14:00:00 +0000</pubDate>
				<category><![CDATA[Engineering]]></category>
		<category><![CDATA[deno]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[typescript]]></category>
		<guid isPermaLink="false">https://www2.cleverapps.io/wp/blog/technology/2020/05/19/deploy-deno/</guid>

					<description><![CDATA[<p><img width="1400" height="540" src="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/denobanner1-1.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/denobanner1-1.png 1400w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/denobanner1-1-300x116.png 300w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/denobanner1-1-1024x395.png 1024w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/denobanner1-1-768x296.png 768w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/denobanner1-1-1368x528.png 1368w" sizes="(max-width: 1400px) 100vw, 1400px" /></p>Rejoice! The long-awaited <a href="https://deno.land/v1">Deno 1.0</a> release is among us. What is Deno you ask?

<span id="more-2826"></span>
<blockquote>Deno is a simple, modern and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust.</blockquote>
More Rust code is often something that makes us happy at Clever Cloud. So purely based on this, and because we like new, shiny toys, here's how to deploy a Deno application on Clever Cloud.

Clever Cloud being a PaaS, there are a bunch of things that can happen automatically, some that can be configured through environment variables. But Deno is not fully integrated to all our tooling yet, so instead we are going to use a NodeJS application with a twist.

I am going to assume you already have our CLI <a href="https://github.com/CleverCloud/clever-tools/">Clever-tools</a> installed, npm and git as well.

First thing first, create a git repo and a node package:
<pre><code class="language-bash">git init
npm init
</code></pre>
Then we install Deno. And if there is something I do not like, it's executing arbitrary shell script from the internet. So I am not going to use their installer. Deno is available as a downloadable binary from their Github Repo. It will do just fine in our case. Create a new folder for your application. From now on every file should be created in that folder.

Here's a shell script that will manage the download and extraction of a specific Deno version:
<pre><code class="language-bash">wget https://github.com/denoland/deno/releases/download/$DENO_VERSION/deno-x86_64-unknown-linux-gnu.zip
unzip deno-x86_64-unknown-linux-gnu.zip
</code></pre>
Notice the use of <code>$DENO_VERSION</code> that will define which one will be downloaded. Let's call this file <code>installdeno.sh</code> and make it executable:
<pre><code class="language-bash">chmod +x installdeno.sh
</code></pre>
And now we can create the Clever Cloud application:
<pre><code class="language-bash">clever create --type node myDenoApplication
</code></pre>
As I wrote earlier, we can specify custom behavior with environment variable. So let's add one that will automate the installation of Deno with our script and one to specify the version we want:
<pre><code class="language-bash">clever env set CC_PRE_BUILD_HOOK ./installdeno.sh
clever env set DENO_VERSION v1.0.0 
</code></pre>
You can execute arbitrary scripts during the deployment of the application; here we want to execute <code>installdeno.sh</code> before the build phase. You'll find the list of hooks in our <a href="https://stagingv6.cleverapps.io/doc/clever-cloud-overview/hooks/">dedicated documentation</a>.

For the application itself, I took a look at the available Deno module and because I am super lazy I chose the first web framework of the list, <a href="https://github.com/zhmushan/abc">abc</a>. There is an Hello World example in the Readme, that's perfect for this test. So go ahead and create <code>abc.js</code> with the following content:
<pre><code class="language-javascript">import { Application } from "https://deno.land/x/abc/mod.ts";

const app = new Application();

app
  .get("/", (c) =&gt; {
    return "Hello, Abc!";
  })
  .start({ port: 8080 });
</code></pre>
The remaining question is, how do we launch this application? Remember that on Clever Cloud, the run process looks at your <code>package.json</code> the <code>main</code> file or <code>start</code> script to know what to execute. Let's use this to our advantage and simply add a start script that uses the Deno binary downloaded by the script.
<pre><code class="language-json">{
  "name": "abc-test",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "start":"./deno run --allow-net abc.js",
    "test": "echo \"Error: no test specified\" &amp;&amp; exit 1"
  },
  "author": "",
  "license": "ISC"
}
</code></pre>
The only thing left to do is to commit your code and deploy it:
<pre><code class="language-bash">git add abc.js installdeno.sh package.json
clever deploy
</code></pre>
From there you should see logs of your deployment showing up. The final message should be <code>Deployment successful</code>. Now type <code>clever open</code> and it will automatically open the website in your default browser.

Granted, this is a little raw and it could feel like cheating but it works and your app benefits from all the Clever Cloud good stuffs, just like any another application:
<ul>
 	<li>environment variables injection</li>
 	<li>monitoring &amp; alerting (auto restart)</li>
 	<li>zero downtime deployments</li>
 	<li>metrics (data &amp; charts)</li>
 	<li>live logs</li>
 	<li>automatic scalability</li>
</ul>
If we see a growing interest in Deno in our community we will make sure it's available with a proper, dedicated and simpler support. Let us know what you think about it and if you intend to use it!]]></description>
										<content:encoded><![CDATA[<p><img width="1400" height="540" src="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/denobanner1-1.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/denobanner1-1.png 1400w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/denobanner1-1-300x116.png 300w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/denobanner1-1-1024x395.png 1024w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/denobanner1-1-768x296.png 768w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/denobanner1-1-1368x528.png 1368w" sizes="(max-width: 1400px) 100vw, 1400px" /></p>Rejoice! The long-awaited <a href="https://deno.land/v1">Deno 1.0</a> release is among us. What is Deno you ask?

<span id="more-2826"></span>
<blockquote>Deno is a simple, modern and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust.</blockquote>
More Rust code is often something that makes us happy at Clever Cloud. So purely based on this, and because we like new, shiny toys, here's how to deploy a Deno application on Clever Cloud.

Clever Cloud being a PaaS, there are a bunch of things that can happen automatically, some that can be configured through environment variables. But Deno is not fully integrated to all our tooling yet, so instead we are going to use a NodeJS application with a twist.

I am going to assume you already have our CLI <a href="https://github.com/CleverCloud/clever-tools/">Clever-tools</a> installed, npm and git as well.

First thing first, create a git repo and a node package:
<pre><code class="language-bash">git init
npm init
</code></pre>
Then we install Deno. And if there is something I do not like, it's executing arbitrary shell script from the internet. So I am not going to use their installer. Deno is available as a downloadable binary from their Github Repo. It will do just fine in our case. Create a new folder for your application. From now on every file should be created in that folder.

Here's a shell script that will manage the download and extraction of a specific Deno version:
<pre><code class="language-bash">wget https://github.com/denoland/deno/releases/download/$DENO_VERSION/deno-x86_64-unknown-linux-gnu.zip
unzip deno-x86_64-unknown-linux-gnu.zip
</code></pre>
Notice the use of <code>$DENO_VERSION</code> that will define which one will be downloaded. Let's call this file <code>installdeno.sh</code> and make it executable:
<pre><code class="language-bash">chmod +x installdeno.sh
</code></pre>
And now we can create the Clever Cloud application:
<pre><code class="language-bash">clever create --type node myDenoApplication
</code></pre>
As I wrote earlier, we can specify custom behavior with environment variable. So let's add one that will automate the installation of Deno with our script and one to specify the version we want:
<pre><code class="language-bash">clever env set CC_PRE_BUILD_HOOK ./installdeno.sh
clever env set DENO_VERSION v1.0.0 
</code></pre>
You can execute arbitrary scripts during the deployment of the application; here we want to execute <code>installdeno.sh</code> before the build phase. You'll find the list of hooks in our <a href="https://stagingv6.cleverapps.io/doc/clever-cloud-overview/hooks/">dedicated documentation</a>.

For the application itself, I took a look at the available Deno module and because I am super lazy I chose the first web framework of the list, <a href="https://github.com/zhmushan/abc">abc</a>. There is an Hello World example in the Readme, that's perfect for this test. So go ahead and create <code>abc.js</code> with the following content:
<pre><code class="language-javascript">import { Application } from "https://deno.land/x/abc/mod.ts";

const app = new Application();

app
  .get("/", (c) =&gt; {
    return "Hello, Abc!";
  })
  .start({ port: 8080 });
</code></pre>
The remaining question is, how do we launch this application? Remember that on Clever Cloud, the run process looks at your <code>package.json</code> the <code>main</code> file or <code>start</code> script to know what to execute. Let's use this to our advantage and simply add a start script that uses the Deno binary downloaded by the script.
<pre><code class="language-json">{
  "name": "abc-test",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "start":"./deno run --allow-net abc.js",
    "test": "echo \"Error: no test specified\" &amp;&amp; exit 1"
  },
  "author": "",
  "license": "ISC"
}
</code></pre>
The only thing left to do is to commit your code and deploy it:
<pre><code class="language-bash">git add abc.js installdeno.sh package.json
clever deploy
</code></pre>
From there you should see logs of your deployment showing up. The final message should be <code>Deployment successful</code>. Now type <code>clever open</code> and it will automatically open the website in your default browser.

Granted, this is a little raw and it could feel like cheating but it works and your app benefits from all the Clever Cloud good stuffs, just like any another application:
<ul>
 	<li>environment variables injection</li>
 	<li>monitoring &amp; alerting (auto restart)</li>
 	<li>zero downtime deployments</li>
 	<li>metrics (data &amp; charts)</li>
 	<li>live logs</li>
 	<li>automatic scalability</li>
</ul>
If we see a growing interest in Deno in our community we will make sure it's available with a proper, dedicated and simpler support. Let us know what you think about it and if you intend to use it!]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
