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

node-seneca-base

v1.0.0

Published

Docker base image for Seneca microservices

Downloads

5

Readme

seneca-node-base

An npm module and Docker base image comprising a few dependencies commonly used in Node.js microservices. This repo demonstrates how using a base layer for microservices can significantly reduce build and deployment time and reduce resources on the runtime host.

Why

Node.js microservices normally have very little code, sometimes less than 100 lines of JavaScript. Having a few NPM dependencies can result in large Docker image layers (100s of MB). This effect increases the time and cost of builds, deployment, transfer and storage. By pushing infrequently updated dependencies into a base layer, time and resource waste can be avoided.

  • docker build times can be reduced from minutes to a few seconds or less
  • docker push times can be reduced from minutes to a few seconds or less
  • Continuous build is faster
  • Development bringup is faster
  • Time spent updating dependencies across many microservices, e.g. in the event of a security patch, is optimised to one core update
  • Resources on the Docker host where multiple microservices are deployed can be optimised by the host kernel as they are sharing the same virtual filesystem.

How

Common dependencies from your microservice toolkit can be wrapped in a Node module and exposed to dependent modules. Using npm link, containers can use the base layer to find these dependencies. Each of your microservices can include seneca-node-base as a package dependency. You can choose to npm link it for development or npm install. For build, test and deployment, no npm install occurs as the dependency is linked from the filesystem in the base layer.

What

This repo is a simple example of how to do this. It contains

  • A set of dependencies, like Seneca.js, Hapi and Lodash
  • A module for exposing those dependencies to derived modules (microservices)
  • A Dockerfile for building the base layer to be reused in microservice image builds
  • A set of three example derives containers - two microservices and an API gateway

Try It

The included examples provide Dockerfiles to show how this works. Together, they make up a primitive user messaging app. The three containers are:

  • A microservice that can add and list users
  • A microservie that allows users to post and view message
  • An API gateway that exposes the first two with HTTP APIs
  • The RabbitMQ library image, used for Seneca transport between microservices

It can be tried like this. The base layer is already built and published on DockerHub, so the examples can be built and run with Docker Compose.

cd examples
docker-compose up -d

This builds and runs up each of the required containers. The API can be exercised to see the full application in action.

curl -H 'Content-Type: application/json' -X POST -d '{"email":"[email protected]","name":"Jo"}' http://$DOCKER_HOST:3000/api/user/add
curl http://$DOCKER_HOST:3000/api/user/list
curl -H 'Content-Type: application/json' -X POST -d '{"user":{"email":"[email protected]","name":"Jo"}, "text":"Hello there!"}' http://$DOCKER_HOST:3000/api/message/post
curl http://$DOCKER_HOST:3000/api/message/list