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

dockerpuller

v1.0.1

Published

Tiny microservice/cli that will push/pull Docker images for you

Downloads

5

Readme

Dockerpuller

A tiny microservice/cli tool that will push/pull Docker images for you.


Build Status npm Vave Code Style

Why?

Let's say you need to deploy a Docker container to your staging machine after your CI tests are done. You might have a section in your .travis.yml (or other .yml) that has something like this:

after_success:
  - docker build -t me/my-container .
  - docker push me/my-conainer
  - ./scripts/deploy.sh

And then in your deploy.sh something like:

#!/bin/bash
ssh deploy@$MY_SECRET_SERVER << EOF
docker stop my-killer-app
docker rm my-killer-app
docker rmi me/my-container:current
docker pull me/my-container:latest
docker tag me/my-container:latest me/my-container:current
docker run -d --restart always --name my-killer-app -p 3000:3000 me/my-container
EOF

And that sort of does the job, but every time you set up a new project you need to do a bunch of setup like SSH keys, putting that deploy.sh in the project, etc.

With Dockerpuller you can just put

"scripts": {
    "deploy": "dockerpuller --deploy"
}

And run npm run deploy instead of that deploy.sh script.

Awesome! How do I set it up?

Step 1.

Okay, first things first, install Dockerpuller globally on your Docker host:

npm install -g dockerpuller

Step 2.

After that, set the DOCKERPULLER_SECRET and optionally PORT environment variables and start Dockerpuller:

PORT=7777 DOCKERPULLER_SECRET="PorgsWereNotOverused12345" dockerpuller

To run it as a service, you can use PM2 or Forever.

Step 2.5.

Then in your CI create the DOCKERPULLER_SECRET environment variable and set it to the same value as on your Docker host.

Step 3.

Configure your project. Install Dockerpuller and add deploy script to your package.json:

npm install --save-dev dockerpuller
"scripts": {
    "deploy": "dockerpuller --deploy"
}

By default, Dockerpuller will read config from package.json, so let's also add that:

"scripts": {
    "deploy": "dockerpuller --deploy"
},
"config": {
    "dockerpuller": {
        "host": "http://mydockerhost.com:7777",
        "image": "me/my-container",
        "ports": "3000:3000",
        "name": "my-killer-app"
    }
}

If you don't want to add config field to your package.json, Dockerpuller also supports respective CLI options. Or CURL. Both will be explained in a bit.

NOTE: Dockerpuller will not create Dockerfile for you. Don't forget to have it in place.

Step 4.

Change your .travis.yml (or other .yml) to the following:

after_success:
  - docker build -t me/my-container .
  - docker push me/my-conainer
-  - ./scripts/deploy.sh
+  - npm run deploy

Step 4.25

By the way, you can have Dockerpuller build the container for you by adding a --build option. Let's do that:

package.json:

"scripts": {
	"deploy": "dockerpuller --build --deploy"
}

.travis.yml (or other .yml)

after_success:
-  - docker build -t me/my-container .
-  - docker push me/my-conainer
-  - ./scripts/deploy.sh
+  - npm run deploy

And you're done! Now just let the magic happen.

CLI Options

If you don't want to set config in package.json, Dockerpuller supports following CLI options:

  • -h, --host [host] - Config: Docker host URL
  • -n, --name [name] - Config: Docker container name
  • -p, --ports [ports] - Config: Port bindings (i.e. 80:3000)
  • --deploy - Run deployment
  • --build - Build an image before deploying

CURL usage

If you don't want to add Dockerpuller to your project's dependencies (no one wants another dependency), you can run your deployment by running a CURL command on your CI:

curl -X "POST" "http://mydockerhost:7777" \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{ \
    "secret": "'"$DOCKERPULLER_SECRET"'", \
    "ports": "80:3000", \
    "container": "me/my-container", \
    "name": "my-killer-app" \
}'

And you're done!