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

new-dockerfile

v0.5.2

Published

Autogenerate Dockerfiles from your project source code

Downloads

49

Readme

Dockerfile Generator

new-dockerfile is a CLI tool and Go package automatically generates a configurable Dockerfile based on your project source code. It supports a wide range of languages and frameworks, including Next.js, Node.js, Python, Ruby, Java/Spring Boot, Go, Elixir/Phoenix, and more.

See the GitHub Repository for full runtime documentation.

See the FlexStack Documentation page for FlexStack-specific documentation related to this tool.

Features

  • [x] Automatically detect the runtime and framework used by your project
  • [x] Use version managers like asdf, nvm, rbenv, and pyenv to install the correct version of the runtime
  • [x] Make a best effort to detect any install, build, and start commands
  • [x] Generate a Dockerfile with sensible defaults that are configurable via Docker Build Args
  • [x] Support for a wide range of the most popular languages and frameworks including Next.js, Phoenix, Spring Boot, Django, and more
  • [x] Use Debian Slim as the runtime image for a smaller image size and better security, while still supporting the most common dependencies and avoiding deployment headaches caused by Alpine Linux gotchas
  • [x] Includes wget in the runtime image for adding health checks to services, e.g. wget -nv -t1 --spider 'http://localhost:8080/healthz' || exit 1
  • [x] Use multi-stage builds to reduce the size of the final image
  • [x] Run the application as a non-root user for better security
  • [x] Supports multi-platform images that run on both x86 and ARM CPU architectures

Supported Runtimes

  • Bun
  • Deno
  • Docker
  • Elixir
  • Go
  • Java
  • Next.js
  • Node.js
  • PHP
  • Python
  • Ruby
  • Rust
  • Static (HTML, CSS, JS)

Usage

Using npx:

npx new-dockerfile [options]

Install the CLI globally:

npm install -g new-dockerfile

Options

  • --path - Path to the project source code (default: .)
  • --write - Write the generated Dockerfile to the project at the specified path (default: false)
  • --runtime - Force a specific runtime, e.g. node (default: auto)
  • --quiet - Disable all logging except for errors (default: false)
  • --help - Show help

Examples

Print the generated Dockerfile to the console:

new-dockerfile

Write a Dockerfile to the current directory:

new-dockerfile --write

Write a Dockerfile to a specific directory:

new-dockerfile > path/to/Dockerfile

Force a specific runtime:

new-dockerfile --runtime next.js

List the supported runtimes:

new-dockerfile --runtime list

How it Works

The tool searches for common files and directories in your project to determine the runtime and framework. For example, if it finds a package.json file, it will assume the project is a Node.js project unless a next.config.js file is present, in which case it will assume the project is a Next.js project.

From there, it will read any .tool-versions or other version manager files to determine the correct version of the runtime to install. It will then make a best effort to detect any install, build, and start commands. For example, a serve, start, start:prod command in a package.json file will be used as the start command.

Runtimes are matched against in the order they appear when you run new-dockerfile --runtime list.

Read on to see runtime-specific examples and how to configure the generated Dockerfile.

Used By

  • FlexStack - A platform that simplifies the deployment of containerized applications to AWS. FlexStack uses this tool to automatically detect the runtime and framework used by your project, so you can just bring your code and deploy it with confidence.
  • Your project here - If you're using this tool in your project, let us know! We'd love to feature you here.