npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@flownet/lib-to-docker

v0.3.15

Published

The **@flownet/lib-to-docker** project provides a straightforward approach for transforming your Node.js applications into Docker images. It automates the process of rendering template files and setting up the necessary project structure to produce Docker

Downloads

130

Readme

@flownet/lib-to-docker

The @flownet/lib-to-docker project provides a straightforward approach for transforming your Node.js applications into Docker images. It automates the process of rendering template files and setting up the necessary project structure to produce Docker-compatible outputs.

How It Works

@flownet/lib-to-docker streamlines the conversion of your project resources into a Docker image through a few key steps:

  1. Template Rendering: It utilizes specified template directories to render configuration files, informing Docker's build process.
  2. File Management: It ensures that all necessary project files are placed correctly within output directories in preparation for Docker image creation.
  3. Docker Image Creation: It automates the Docker build process using a build script, producing a Docker image ready for deployment.

Key Features

  • Automated Directory Setup: Creates and organizes necessary directories for output and packaging.
  • Template Integration: Renders Docker configuration files from templates, ensuring customizability and reuse.
  • File Handling: Manages project files, including handling content, decoding base64, and copying files, to prepare them for the Docker image.
  • Docker Build Automation: Simplifies the Docker image creation process through automated builds using shell scripts.

Conclusion

The @flownet/lib-to-docker project offers a simplistic yet effective solution to package Node.js applications into Docker images efficiently. It simplifies the often complex preparatory steps required for Dockerization, focusing on seamless integration and ease of use.

Developer Guide for @flownet/lib-to-docker

Overview

@flownet/lib-to-docker is a Node.js library designed to assist developers in creating Docker images from application source directories. Its core functionality includes setting up a Docker build by managing necessary files, rendering templates, and executing Docker commands. This library facilitates easy integration of Docker build processes into existing projects, streamlining the setup for efficient containerization.

Installation

To include @flownet/lib-to-docker in your project, you can install it using npm or yarn. It automatically handles any external dependencies, so you don't need to worry about them during installation.

npm install @flownet/lib-to-docker

or

yarn add @flownet/lib-to-docker

Usage

Using @flownet/lib-to-docker, you can convert your project into a Docker-ready directory that includes necessary configuration files and execute the Docker build command. Here’s a basic way to utilize the library in your application:

  1. Import the library and any required modules.
  2. Set up your source and destination paths.
  3. Configure the parameters for image generation, such as image name, base image, and any specific files to be included.
  4. Call the library’s functions to render templates and build your Docker image.

Examples

Below are code examples illustrating common use cases:

Example 1: Basic Docker Image Setup

Create a basic Docker image using your application's dist directory.

import libToDocker from '@flownet/lib-to-docker';

const config = {
  params: {
    name: "my-docker-app",
    version: "1.0.0",
    image_base: "node:20-alpine",
    template: "docker"
  },
  config: {
    files: [
      { path: './config/app.json', content: '{"key": "value"}' }
    ]
  },
  src: './path/to/your/source',
  dest: './output/destination'
};

libToDocker(config).then(() => {
  console.log("Docker image setup complete!");
}).catch(error => {
  console.error("Image setup failed:", error);
});

Example 2: Using Custom Templates

If you have custom template requirements for Docker setup, specify additional template directories:

import libToDocker from '@flownet/lib-to-docker';

const config = {
  params: {
    name: "custom-app",
    additional_template_dir: './path/to/custom/templates'
  },
  config: {
    files: [
      { path: './config/settings.json', content: '{"theme": "dark"}' }
    ]
  },
  src: './source',
  dest: './build'
};

libToDocker(config).then(() => {
  console.log("Custom Docker setup complete!");
}).catch(error => {
  console.error("Setup error:", error);
});

Acknowledgement

This guide outlines the functionality of @flownet/lib-to-docker for building Docker images efficiently, recognizing the contributions of the Flownet team in its development.

Input Schema

$schema: https://json-schema.org/draft/2020-12/schema
type: object
properties:
  params:
    type: object
    properties:
      name:
        type: string
        description: The name of the docker project
        default: docker
      id:
        type: string
        description: The identifier for the docker project
        default: com.example.docker
      version:
        type: string
        description: The version of the docker project
        default: 0.1.0
      image_base:
        type: string
        description: The base image for the docker project
        default: node:20-alpine
      image_name:
        type: string
        description: The name of the docker image
        default:
          $ref: "#/properties/params/properties/name/default"
      template:
        type: string
        description: The template for the docker project
        default: docker
      title:
        type: string
        description: The title of the docker project
        default: Docker Image
      package_name:
        type: string
        description: The package name of the docker project
        default:
          $ref: "#/properties/params/properties/name/default"
      author:
        type: string
        description: The author of the docker project
        default: Flownet
      description:
        type: string
        description: The description of the docker project
        default: Docker Image built with Flownet
      vendor:
        type: string
        description: The vendor of the docker project
        default: flownet.ai
      package_dir:
        type: string
        description: The directory for docker package
        default: ./.package/docker
      out_dir:
        type: string
        description: The output directory for docker build
        default: ./.out/docker
  config:
    type: object
    properties:
      files:
        type: array
        description: The files to handle within config
        items:
          type: object
          properties:
            path:
              type: string
              description: Path for a given file
            srcfile:
              type: string
              description: Source file path
            content:
              type: string
              description: Content of the file
            base64:
              type: string
              description: Base64-encoded content of the file
required:
  - params
  - config
  - src
  - dest