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

dockerc

v1.0.0

Published

CLI wrapper for docker build and run services based on `docker-compose.yaml` in frontend project

Downloads

10

Readme

Docker Compose Wrapper CLI

CLI wrapper for docker build and run services based on docker-compose.yaml in frontend project.

The only thing we concern is the dynamic version number.

oclif CircleCI GitHub license

Prerequisites

  • Docker installed
  • Docker compose installed - Can use docker compose command
  • Docker Service started
  • docker-compose.yaml file existed in cwd

Features

  • Image version existence check
  • Use semver version
  • Use name and version fields of package.json default

Installation

npm i -g dockerc

Usage

Assume that there is the following Dockerfile file:

FROM nginx:1.24.0-alpine-slim

COPY --chown=nginx:nginx ./dist /usr/share/nginx/html
COPY ./nginx.conf /etc/nginx/templates/default.conf.template

ARG VERSION="v0.0.0"
ENV VERSION=${VERSION}

And the following docker-compose.yaml file:

version: "3"
services:
  build:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        VERSION: ${VERSION}
    image: ${IMAGE_NAME}:${VERSION}

  dev:
    image: nginx:1.24.0
    container_name: example-dev
    restart: unless-stopped
    volumes:
      - ./dist:/usr/share/nginx/html
      - ./nginx.conf:/etc/nginx/templates/default.conf.template
    ports:
      - 8080:80

  prod:
    image: ${IMAGE_NAME}:${VERSION}
    container_name: example-prod
    restart: unless-stopped
    ports:
      - 80:80

Commands

dockerc build

Build docker images with build service in docker-compose.yaml file.

USAGE
  $ dockerc build [--image <value>] [--no-export] [--version <value>]

FLAGS
  --image=<value>    Docker image name. Use the `name` field of the `package.json` file in CWD.
  --no-export        Don't export image after the docker build is successful.
  --version=<value>  Docker image version. Use the `version` field of the `package.json` file in CWD.

DESCRIPTION
  Build docker images with `build` service in `docker-compose.yaml` file.
  It will inject `IMAGE_NAME` and `VERSION` environment variables.

EXAMPLES
  $ dockerc build    # Use the `name` and `version` field of the `package.json` file in CWD.

  $ dockerc build --image example    # Specify image name

  $ dockerc build --version 1.0.0    # Specify image version

See code: src/commands/build.ts

dockerc dev

Start dev service in docker-compose.yaml file.

USAGE
  $ dockerc dev

DESCRIPTION
  Start `dev` service in `docker-compose.yaml` file.

EXAMPLES
  $ dockerc dev

See code: src/commands/dev.ts

dockerc help [COMMANDS]

Display help for dockerc.

USAGE
  $ dockerc help [COMMANDS] [-n]

ARGUMENTS
  COMMANDS  Command to show help for.

FLAGS
  -n, --nested-commands  Include all nested commands in the output.

DESCRIPTION
  Display help for dockerc.

See code: @oclif/plugin-help

dockerc prod

Start prod service in docker-compose.yaml file.

USAGE
  $ dockerc prod [--image <value>]

FLAGS
  --image=<value>  Docker image name. Use the `name` field of the `package.json` file in CWD.

DESCRIPTION
  Start `prod` service in `docker-compose.yaml` file.
  The docker image will be selected from the existing image list
  It will inject `IMAGE_NAME` and `VERSION` environment variables.

EXAMPLES
  $ dockerc prod    # Use the `name` field of the `package.json` file in CWD.

  $ dockerc prod --image example    # Specify image name

See code: src/commands/prod.ts

Integration

release-it

# .release-it.yaml
# omit other configuration
hooks:
  "after:release": "dockerc build --version ${version}"

Development

Clone the repository

git clone https://github.com/jxsylar/dockerc

Install dependencies

pnpm i

Also, It will run build automatic.

Install CLI global

npm link

It will install to $(npm prefix root -g)/bin/ folder, make sure this path is in PATH env.

Now you can use dockerc command in your shell:

docker

Update

After code changed, build again:

pnpm run build

And the dockerc command will automatic use the latest version, which means you don't need to run npm link again.

Document

Automatically update README.md by running:

pnpm run doc

Note: The command must run after building.

Uninstall

npm unlink -g dockerc

This command can run in any path, which means you don't need to cd the project path.

Reference

Docker compose file variable interpolation