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

hyzone

v0.0.3

Published

Docker local orchestrator, Docker Compose but better

Downloads

2

Readme

Hyzone

Docker orchestration for local/CI environment for Linux users. It might be a better alternative to Docker Compose.

It's bash-based but you don't need to know bash to use it if you know basics of *nix based shell. Although bash knowledge gives you more power over hyzone. Additionally you should be quite familiar with Docker.

If you don't understand below example then it is adviced that you familiarize yourself with Linux shell and bash scripting a little bit and/or Docker.

Quick links:

Introduction

Hyzone uses similar concept to docker-compose.yml. Hyzone config file is named hyzone.cfg or hyzone.bash. This file is in bash. It has numerous user-defined functions. Each function can represent either a container or some task to be run (e.g. run multiple containers or check state of the system). Example file:

PROJECT_NAME="myproj"

backend_dockerfile="$(pwd)/backend/Dockerfile"
backend_context="$(pwd)/backend"

backend () {
  docker run -d -v "$(pwd)/backend:/w" -w /w $HYZONE_OPTS node index.js
}

# If we use predefined docker image then just add it after "$HYZONE_OPTS"
frontend () {
  docker run -d -v "$(pwd)/frontend:/w" -w /w $HYZONE_OPTS nginx
}

$HYZONE_OPTS is a variable that hyzone prefills with connection options, image name, labels etc. that are needed for your convenience and for hyzone to operate.

This example is read-only. After this example you'll get other example to play with (see below).

We would run above configuration file with:

$ hyzone run backend
<some docker/hyzone output>

$ hyzone run frontend
<some docker/hyzone output>

Hyzone managed containers are to be treated as ephemeral.

The philosophy of hyzone is to quickly run environment, easily run manual or automatic tests and quickly tear down whole environment on-demand with all images and network removed if needed.

hyzone run <name> will run container in specially created network (named after PROJECT_NAME). All run commands create containers in this network. All containers are available by their function names, e.g. by backend and frontend hostnames within the network.

You can add normal bash functions to hyzone.cfg. hyzone run $1 will run them as normal functions. You can pass arguments to them normally. For example we can have this kind of hyzone.cfg file:

backend () { ...; }
frontend () { ...; }

api_request () {
  hyzone curl backend:8080/api/$1
}

And then

$ hyzone run api_request /version
{
  "version": "1.1.0"
}

When you run hyzone run $1 again then old container will be killed immediately and removed and new one will be rebuilt/recreated. This is why this technology is for development/CI environment.

Hyzone curl

You can run

$ hyzone curl -s "http://backend:8080/api/user/1"
{
  "name": "Jan",
  "status": "Awesome"
}
$ hyzone curl -s "http://frontend/index.html"
<html>
<body>
  This is awesome!
</body>
</html>

Above responses are example responses from backend and frontend apps.

hyzone curl runs curl in special container within same docker network so you can access containers by their hyzone names (i.e. function names). Docker containers in most cases will be named the same as hyzone names.

Random prefix

For CI convenience you can run hyzone generate_random_prefix that will create random prefix and put it in .hyzone_prefix file.

If .hyzone_prefix file is present then created network name and names of all containers are prefixed with this prefix. All logic will work the same and you can use original names from hyzone.cfg - hyzone, even if docker container names are different, can find your containers by labels.

Random prefix is useful if you run mutilple CI pipelines parallely (e.g. for different branches).

hyzone kill and hyzone clean command will work too.

Tips and tricks

hyzone run <name> && hyzone logs <name> -f to run and tail logs immediately. To restart app just CTRL-C and up arrow and re-execute the command. Remember that hyzone run will kill and rebuild and run the container again.

TODO

  • Update mean-stack example
  • Create more examples
    • Multi-language project example
    • Jenkins pipelines examples with selenium and API tests
  • Finish hyzone with experimental feature.
  • Allow using other languages in bash functions which is an experimental feature.

License MIT