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

container-crane

v1.0.2

Published

WebHook listener. Deploy your app with a single 'git push production'.

Downloads

11

Readme

container crane

Listen for webhooks and execute a deployment script

By v-braun - www.dev-things.net.

Description

Express based HTTP Endpoint that listens to webhooks. Downloads a file named deploy.crane from the repository and executes it.

I use it with Gogs to deploy my Docker container to a production environment.

Installation

Standalone installation

Install it globally:

npm install container-crane -g

and then start it:

container-crane

As a Docker container

# (optional )Create a network for Gogs and container-crane (not port mappings required)
docker network create deployment-net

# Pull image from Docker Hub.
docker pull devthings/container-crane

# Use `docker run` for the first time.
# map the docker.sock from host within the container
# if you want to use docker commands in your deploy scripts 
# (to deploy "neighbor" containers).
docker run --name="container-crane" --net="deployment-net" --restart=always -d -v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):/bin/docker devthings/container-crane

# Use `docker start` if you have stopped it.
docker start container-crane

# (optional) Restart your Gogs container within the deployment-net network
# docker run --name="gogs" --net=deployment-net // other params

Usage

Setup a webhook in your Gogs repository that points to the /gogs/ endpoint of the container-crane container:

image

Now you need a deployment script for your app. You can write it in bash or node (both is installed on the container-crane Docker image)

Create a file named deploy.crane within your repository.

Here is an example as a bash script:

#! /bin/bash
echo "stop the container"
docker stop my-app
echo "remove container"
docker rm my-app
echo "build image"
docker build -t my-app --force-rm=true http://gogs:3000/my-gogs-user/my-app.git
echo "run the container"
docker run --name=my-app --restart=always -d -p 3000:3000 my-app

NOTE: container-crane depends not on docker! The deploy.crane script depends on your hosting environment.

Now you can simply:

git push your-gogs-origin

After container-crane receive a POST request from Gogs, it parses the webhook request body and downloads a script named deploy.crane. When the file is downloaded it will be executed.

FEATURES

  • [x] Installation as container from Docker Hub
  • [x] Handle secret from Gogs request
  • [ ] Support other endpoints:
    • GitHub
    • Slack

Tests

To execute tests run:

npm test

To execute tests with watch run:

npm run dev

Known Issues

If you discover any bugs, feel free to create an issue on GitHub fork and send me a pull request.

Issues List.

Authors

image
v-braun

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

See LICENSE.