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

dockerfilejs

v1.2.1

Published

Dockerfile-js, render well-formed Dockerfiles.

Downloads

29

Readme

Build Status Coverage Status

Dockerfilejs

A simple Dockerfile generator. Try it now!

Based on the official Dockerfile Reference

var Dockerfile = require("dockerfilejs").Dockerfile;
var file = new Dockerfile();

file.comment('The above code example yields this file!')
  .env({DEBUG:'express:* node index.js'})
  .expose(8080)
  .separator('\n')
  .from({ image : 'node', tag : 'latest'})
  .comment('FROM gets bumped under initial comments')
  .render();
# The above code example yields this file!
FROM node:latest
ENV DEBUG="express:* node index.js"
EXPOSE 8080
# FROM gets bumped under initial comments

Complex environment? No problem!

file.env({
    complex: {
        objects:  'are not',
        a: 'problem',
        at : {
            all: 'really!'
        }
}}).render();
/*
ENV complex.objects="are not" \
    complex.a=problem \
    complex.at.all=really!
*/

Made a mistake? Get rid of it!

file.copy('~/.ssh/*', '/tmp');
// oops!
file.steps().pop();

Advanced examples

file.separator('\n')
// Will set the separator of each step for the entire file.render() output

file.label({ complex: { objects: 'allowed' } });
// LABEL complex.objects="allowed"

file.expose([8080, '8081', { number: 443, protocol: 'tcp' }]);
// EXPOSE 8080 8081 443/tcp

file.run({ command: ['touch /file.txt', ['echo', 'hello world', '>>', '/file.txt'] ] });
// RUN touch /file.txt \
//   && echo "hello world" >> /file.txt

file.copy({ src : ['/id_rsa', '/id_rsa.pub'], dest: '/root/.ssh/' }, true);
// ONBUILD COPY ["/id_rsa", "/id_rsa.pub", "/root/.ssh"]

file.copy({ src : ['/id_rsa', '/id_rsa.pub'], dest: '/root/.ssh/', onbuild: true });
// ONBUILD COPY ["/id_rsa", "/id_rsa.pub", "/root/.ssh"]

file.copy({ src : ['/id_rsa'], dest: '/root/.ssh/', chown: '0:0' });
// COPY --chown=0:0 ["/id_rsa", "/root/.ssh"]

file.copy({ src : ['/id_rsa'], dest: '/root/.ssh/', user: 0, group: 0 });
// COPY --chown=0:0 ["/id_rsa", "/root/.ssh"]

file.copy({ src : ['/id_rsa'], dest: '/root/.ssh/', chown: { user: 0, group: 0 });
// COPY --chown=0:0 ["/id_rsa", "/root/.ssh"]

file.cmd({ executable: '/bin/bash', params: ['-c', 'hello world'] });
// CMD ["/bin/bash", "-c", "hello world"]

file.cmd({ command:'/bin/bash', params: ['-c', 'hello world'] })
// CMD /bin/bash -c "hello world"

file.healthCheck({
    options: { retries: 4, timeout: '30s'},
    command: 'wget',
    params: ['example.com']
})
// HEALTHCHECK --retries=4 --timeout=30s \
//   CMD wget example.com

file.user('root');
// USER root

Multi-stage builds

file.from({ image: 'node', tag: '10-alpine', name: 'build' })
// FROM node:10-alpine AS build

// ... run your build commands here ...

file.stage()
// Adds a new stage

file.from({ image: 'node', registry: 'docker.io', tag: '10-alpine' })
// Sets the `FROM` instruction in the new stage, etc ...

file.copy({ from: 'build', src: ['./lib'], dest: './lib' })
// COPY --from=build ["./lib", "./lib"]