Source-to-image project for Deno applications

Source-to-image project for Deno applications

This project is just for exploring what a to-image (s2i) might look like for Deno applications.The idea here is that the s2i will provide the Deno runtime, and take a users Typescript application and bundle

ubi8-s2i-deno

This project is just for exploring what a to-image (s2i) might look like for Deno applications.

The idea here is that the s2i will provide the Deno runtime, and take a users Typescript application and bundle, which is a feature in Deno which takes the application and I think what it does is resovles dependencies and compiles the Typescript into JavaScript which can then be executed by the Deno runtime. Doing this in the assemble stage will mean that the startup time is improved.

Build this image:

$ podman build -t nodeshift/ubi8-s2i-deno .

Run the image:

$ podman run -it localhost/ubi8-s2i-deno /bin/bash

Build an s2i example-app, specifying which Typescript file is the main entry point using the MAIN build argument, and also shows how a PERMISSION option can be passed to the build.:

$ cd example-app
$ podman build . --build-arg MAIN=welcome.ts --build-arg PERMISSIONS="--allow-read=/etc" -t app

The PERMISSION build argument is an example of using Deno's permissions to allow the application to read from the file system. Without this flag the an error would be produced at runtime:

error: Uncaught PermissionDenied: read access to "/etc/passwd", run again with the --allow-read flag
    at processResponse (core.js:226:13)
    at Object.jsonOpSync (core.js:250:12)
    at Object.lstatSync (deno:cli/rt/30_fs.js:216:22)
    at Object.existsSync (file:///opt/app-root/src/main.js:11267:18)
    at execute (file:///opt/app-root/src/main.js:11300:65)
    at gExp (file:///opt/app-root/src/main.js:91:7)
    at __instantiate (file:///opt/app-root/src/main.js:98:27)
    at file:///opt/app-root/src/main.js:11305:1

Running the example app:

$ podman run -t localhost/app 
Welcome to Deno(14:24) 🦕
Does /etc/passwd exist: true

TypeScript config

A TypeScript configuration can be passed to Deno's bundle command using the following option:

$ podman build . --build-arg MAIN=welcome.ts --build-arg TSCONFIG="tsconfig.json"

The tsconfig.json file must be copied to the image, so it need to be added in the DockerFile that uses/extends this image.

TODO

  • The image size is quite large and we might be able to use a smaller base image.
  • Also currently there are no permissions passed on when building but this should not be to difficult to add in the same why that the MAIN entry ts file is specified.

Download Details:

Author: danbev

Source Code: https://github.com/danbev/ubi8-s2i-deno

deno nodejs node javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

AEM Querybuilder for JavaScript (Browser, Node, Deno)

Helix Querybuilder .AEM Querybuilder for JavaScript (Browser, Node, Deno)

NKeys for JavaScript - Node.js, Browsers, and Deno

A public-key signature system based on Ed25519 for the NATS ecosystem system for JavaScript. The nkeys.js library works in Deno, Node.js, and the browser!

Javascript module for easily generating mazes,compatible with both Deno and Node

A work-in-progress Javascript maze generator module, compatible with both Deno and Node.

Deno Tutorial for Beginners: Deno vs. Node: Better Than NodeJS?

Deno is released, it’s time to find out if it can prove a worthy competition for Node.js. What is Deno? Why Deno can be considered an alternative to Node? The main differences between Deno and Node. Write a simple Deno app.

What is Deno? The Node.JS Killer? The Deno-minator to Node?

What is Deno? The Node.JS Killer? The Deno-minator to Node? Deno is the new hype and will it be better than node.js? Deno is a secure runtime for JavaScript and TypeScript that is based on the V8 JavaScript engine and the Rust programming language that addresses Node’s shortcomings