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

dockaless

v0.0.1

Published

Docker containers as composable functions

Downloads

5

Readme

Dockaless - Serverless Docker functions

Integrate Docker containers into a serverless platform or a lambda-based flow via IOpipe.

Examples:

Create a serverless function:

var Dockaless = require("dockaless")

var dals = Dockaless({
  protocol: 'https',
  host: '127.0.0.1',
  port: process.env.DOCKER_PORT || 2375,
  ca: fs.readFileSync('ca.pem'),
  cert: fs.readFileSync('cert.pem'),
  key: fs.readFileSync('key.pem')
})

export.handler = dals.make_lambda("ubuntu", [ "whoami" ])

Resizing videos with FFmpeg:

This may be leveraged with the IOpipe library to chain execution with local functions, remote functions, and APIs.

var iopipe = require("iopipe")()
var Dockaless = require("dockaless")
var dals = Dockaless()

export.handler = iopipe.define(
  iopipe.property("url"),
  iopipe.fetch,
  dals.make_lambda("ffmpeg", [ "-i", "pipe:0", "-vf", "scale=320:240", "pipe:1" ])
)

This example accepts a JSON document containing a "url" key. A video is fetched from this URL and scaled (resized) using ffmpeg. The video is piped back over the network to the caller, but a script could continue by saving this somewhere (such as S3) as in the following example.

Parallelization

This library combined with the IOpipe library can be used to easily build parallelized tasks requiring use of containerized applications.

The following example is similar to the previous, but converts an array of videos, saves them to storage, and returns URLs to the uploaded content.

var AWS = require('aws-sdk');
var iopipe = require("iopipe")()
var Dockaless = require("dockaless")
var crypto = require("crypto")

var dals = Dockaless()
var s3 = new AWS.S3();

function put_bucket(event, context) {
  s3.createBucket({Bucket: event.bucket}, function() {
    var params = {Bucket: event.bucket, Key: event.key, Body: event.body};
    s3.putObject(params, function(err, data) {
        if (err)
            context.fail(err)
        else
            context.succeed(event)
     });
  });
}

export.handler = iopipe.define(
  iopipe.property("urls"),
  iopipe.map(
    iopipe.fetch,
    dals.make_lambda("ffmpeg", [ "-i", "pipe:0", "-vf", "scale=320:240", "pipe:1" ]),
    (event, context) => {
      var video_hash = crypto.createHash('sha256').update(event).digest('hex')
      put_bucket({
        bucket: "your_bucket",
        key: video_hash
      }, context)
    },
    (event, callback) => {
      callback(s3.getSignedUrl('getObject', event))
    }
  )
)

Reference

class Dockaless(dockerode_opts)

If dockerode options are not provided, local environment variables will be used. Typically, this will attempt to manage a local Docker daemon via its Unix socket.

Current options are:

  • host
  • port
  • ca
  • cert
  • key

See dockerode documentation for more details.

method Dockaless.make_lambda(image, cmd)

Image is the name of a Docker image.

Cmd are the arguments for the image, overriding CMD. Depending on if there is an entrypoint defined, this either passes arguments to the entrypoint, or executes the command inside the container. (This is standard Docker behavior)

License

Apache 2.0