Skip to content

getlarge/node-sea-demo

Repository files navigation

NodeSeaDemo

Cover

NodeSeaDemo is a practical demonstration of a Single Executable Application (SEA) built with Node.js and Fastify. This project showcases how to handle file management during compilation, bundling, and runtime in a SEA context.

The application is compiled and bundled with ESBuild before the creation of the blob.

Features

  • HTTP API: A simple HTTP API built with Fastify.
  • Static Assets: Handles bundled static assets.
  • File Uploads: Supports dynamic file uploads.
  • SEA Assets: Manages SEA assets.

Project Structure

  • apps/node-sea-demo: Main application source code.
  • apps/node-sea-demo-e2e: End-to-end tests for the application.
  • dist: Compiled output directory.
  • Dockerfile: Docker configuration for running the application.
  • Dockerfile.sea: Docker configuration for building the SEA bundle.

Getting Started

Prerequisites

  • Node.js >= 20.12.0
  • Docker

Installation

  1. Clone the repository:

    git clone https://github.com/your-repo/node-sea-demo.git
    cd node-sea-demo
  2. Install dependencies:

    npm install
    

Running the Application

To run the application locally:

nx run node-sea-demo:serve

To build and run the SEA:

nx run node-sea-demo:sea-build
./dist/apps/node-sea-demo-sea/node

To build and run the Docker container:

nx run node-sea-demo:docker-sea-build
docker run --rm -p 3000:3000 -t node-sea-demo:sea

Learn More

For more details, refer to the presentation.