joehua87 / node-starter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

node-starter

Why?

I see it's hard & time consuming when deploy node app into production docker, especially with npm install

Features

Node.js preconfig

Fast Docker Build

How it works

  • build src => lib
  • install production dependencies only in docker (use strategy in this article to leverage cache)
  • copy lib & package.json into docker

How it cache

  • If you don't change dependencies (for example: yarn add ...) => it just build src => lib & copy the lib directory into docker. Building time is same as normal npm build
  • It you change devDependencies => it works like statement above
  • If you change dependencies, it will leverage yarn-cache and only install the dependency you just add. And it's just take some seconds to do this

Requirement

  • Node.js
  • Docker

Getting started

  • git clone https://github.com/joehua87/node-starter.git
  • yarn
  • ./build.sh
  • Test that it's work properly: docker run --rm joehua/node-starter node lib/bin/run.js
  • Modify src/bin/run.js
  • ./build.sh
  • Run this again: docker run --rm joehua/node-starter node lib/bin/run.js
  • You will see that the image is up to date, and build time is blazing fast

About

License:MIT License


Languages

Language:JavaScript 62.8%Language:Shell 37.2%