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

friendship-blaster

v1.0.0-beta.6

Published

simple docker-compose based deployments

Downloads

2

Readme

friendship blaster

build status Known Vulnerabilities

This is a tool to run a system of docker containers using docker-compose and update them as new image versions are published.

Usage

As input it takes a docker-compose.yml and a list of containers that can be upgraded. If the docker-compose.yml looks like this:

version: "3"
services:
  my-cat-service:
    image: some-registry:7420/cat-image:10.0.0
  my-dog-service:
    image: some-registry:7420/dog-image:10.0.0
  redis:
    image: redis:5.0-alpine

In the directory containing the docker-compose.yml run this:

friendship-blaster -i dog-image,cat-image

friendship-blaster will run the docker-compose configuration file above in a container with docker-compose installed. While these containers are running, it will poll the container registry at some-registry:7420 every one minute to look for updates to cat-image and dog-image that are above the current version and below the next semantically incompatible version (11.0.0). When it detects an update it will do the following in sequence:

  • Pull the latest images.
  • Shutdown all existing containers.
  • Create a copy of docker-compose.yml but patched to refer to the detected image versions.
  • Restart docker-compose with the patched copy of the original configuration.

Example

Assume the docker-compose.yml exists in the current working directory.

version: "3"
services:
  my-cat-service:
    image: some-registry:7420/cat-image:10.0.0
  my-dog-service:
    image: some-registry:7420/dog-image:10.0.0
  redis:
    image: redis:5.0-alpine

Next the user runs friendship-blaster in this directory:

friendship-blaster --images dog-image,cat-image \
                   --debounce 100 \
                   --poll-interval 100 \
                   -c some-registry:7420:credentials.txt

This directory must also contain a file called credentials.txt which stores the username and password for the container registry some-registry:7420 in the format username:password. The -c argument can be specified multiple times.

When friendship-blaster is first run it runs docker-compose using the docker-compose.yml shown above, and every 100 seconds it polls some-registry:7420 for changes to cat-image and dog-image.

120 seconds later the user pushes a new dog-image with version 10.0.1. 200 seconds later friendship-blaster will see this image when it next polls. However it will not restart docker-compose immediately due to the requested debounce of 100.

180 seconds later the user pushes a new cat-image with version 10.0.2. friendship-blaster will see this change in its second poll, 200 seconds after it was first started.

The user does not push any more images for at least 120 seconds, now at 300 seconds the debounce of 100 has cleared. friendship-blaster will create a file fblaster-docker-compose.yml in the same directory as docker-compose.yml. This file will be identical to the original except that the image versions will specify the latest the docker tags that were detected. It also creates a file fblaster-versions.yml in this directory which will store the reference between the images and their corresponding versions.

Some time later the user decides to shut down friendship-blaster by pressing ctrl-C in the console where it is running. This will in turn cause friendship-blaster to shut down docker-compose. Then some time after this they run friendship-blaster in the same directory again. This time friendship-blaster will load the latest fblaster-versions.yml and create a fblaster-docker-compose.yml reference the latest tagged docker images. It will then resume polling for new versions from this point in time.

Implementation details

friendship-blaster runs inside its own container which has docker-compose and node installed. The friendship-blaster command is a small bash script which executes the friendship-blaster container and mounts /var/run/docker.sock inside of the container. This allows the docker-compose running inside of the container to access docker on the host system.

Testing

To decrease the time you must wait for the friendship-blaster image to be rebuilt during testing iterations yarn test-dev can be used. This runs friendship-blaster using the versions of node and docker-compose installed on the system.