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

dockerized-cli

v0.8.1

Published

dockerized 🏗❤️ ================

Downloads

14

Readme

dockerized 🏗❤️

oclif Version Downloads/week License

dockerized is a tool for seamlessly executing commands in a container. It takes care of the details so you can run a command in a container as if it was running on your machine - just prepend any command with dockerized exec to have it run in the container.

This is especially useful for building things. For example, if your project needs Java and Maven to build, you can put these build dependencies in a Dockerfile and then just replace mvn with dockerized exec mvn. If your tests need a Postgresql database to run, add that in a Docker Compose file and just run dockerized exec mvn test.

That approach encourages versioning the build dependencies alongside the application code.

  • Never again an outdated README file with all the tools you need to install to build your project.
  • Never again your build dependencies managed in another repo which falls out of sync with your code.

Your build dependencies are part of your project!

Why not docker run or docker exec?

Fair question! After all dockerized is just a wrapper for Docker. You can definitely use docker run or docker exec but there are a few details you'd have to take care of:

Rebuilding the Docker image: after changing the Dockerfile, you need to run docker build before running docker run again. When iterating on the Dockerfile this can become a pain.

With dockerized you just do dockerized exec.

Volumes and working directory: to allow the developer to run commands from arbitrary locations within the project, you probably want to mount the project root into the container. Manually running docker run -v $PWD:... one time and docker run -v $PWD/..:... another time, or adding some script to do this for you.

With dockerized you just do dockerized exec.

Running Docker Compose: almost every project has integration tests. Running them locally usually means running Docker Compose. Now you need to run docker-compose up before running docker run. Besides being annoying, see also "Port contamination" below.

With dockerized you just do dockerized exec.

"Port contamination": many people run their tests on the host, against dependencies (think PostgreSQL for example) running in containers. Since the tests need to access the PostgreSQL port, they expose this port to the host. When you are working on multiple projects these exposed ports start conflicting and you have to docker-compose stop one project before docker-compose start the other.

With dockerized you just do dockerized exec.

Getting Started

Install dockerized:

npm install -g dockerized-cli

Run dockerized init to set up. It will create a Dockerfile and a Docker Compose file for you. You can tweak those to set up your build dependencies.

Then run dockerized exec COMMAND to build the container, start the dependencies, and execute COMMAND inside a container.

Contents:

Usage

$ npm install -g dockerized-cli
$ dockerized COMMAND
running command...
$ dockerized (-v|--version|version)
dockerized-cli/0.8.1 linux-x64 node-v8.12.0
$ dockerized --help [COMMAND]
USAGE
  $ dockerized COMMAND
...

Examples

See the src/examples/ folder.

Commands

dockerized clean

removes the container

USAGE
  $ dockerized clean

EXAMPLE
  $ dockerized clean

See code: src/commands/clean.ts

dockerized compose

run a docker-compose command

USAGE
  $ dockerized compose

EXAMPLES
  $ dockerized compose ps
  ...

See code: src/commands/compose.ts

dockerized edit

edit the Dockerfile or Docker Compose file

USAGE
  $ dockerized edit

OPTIONS
  --file=dockerfile|composefile  [default: dockerfile] file to edit

See code: src/commands/edit.ts

dockerized exec [NAME=VALUE ...] COMMAND

execute a command inside the dockerized environment

USAGE
  $ dockerized exec [NAME=VALUE ...] COMMAND

DESCRIPTION
  Environment variables:
     To provide environment variables, either add them in the docker-compose
     file or pass them in the command line:

     dockerized exec FOO=1 BAR=2 COMMAND

EXAMPLES
  $ dockerized exec ls -l
  $ dockerized exec make build
  $ dockerized exec mvn

See code: src/commands/exec.ts

dockerized help [COMMAND]

display help for dockerized

USAGE
  $ dockerized help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

dockerized init

initialize dockerized in this directory (see also: init --help)

USAGE
  $ dockerized init

OPTIONS
  --composeFile=composeFile  [default: .dockerized/docker-compose.dockerized.yml] Docker-Compose file to create
  --dockerFile=dockerFile    [default: .dockerized/Dockerfile.dockerized] Dockerfile to create
  --withGoCache              Includes a volume for GOPATH
  --withNestedDocker         Includes support for running Docker inside Docker
  --withYarnCache            Includes support for utilizing yarn cache

EXAMPLE
  $ dockerized init

See code: src/commands/init.ts

dockerized shell

drop into an interactive shell inside the dockerized

USAGE
  $ dockerized shell

See code: src/commands/shell.ts

Advanced Usage

Environment variables

The environment variables available to the dockerized command consists of:

  • Environment variables defined in .dockerized/Dockerfile.dockerized
  • Environment variables defined in .dockerized/docker-compose.dockerized.yml
  • Environment variables passed to the exec command: dockerized exec FOO=1 BAR=2 COMMAND

Caching the image

dockerized supports caching of the builder image (the image that contains your build dependencies). If you add image to the dockerized service of the Docker Compose file:

dockerized edit --file=composeFile
 services:
   dockerized:
+    image: remote-image-uri:latest
     build:

dockerized will pull that image and use it when building your Dockerfile. The result is faster builds!

My project uses Yarn - how do I utilize its cache?

$ dockerized init --withYarnCache