HUB
Sign inSign up

stevenaldinger/alpine-nodejs-dev

By stevenaldinger

•Updated about 9 years ago

Alpine NodeJS image that can generate minimal images for production or loaded dev images for dev.

Image
0

50K+

stevenaldinger/alpine-nodejs-dev repository overview

⁠Alpine NodeJS App Builder

This contains two Dockerfiles, one for installing dependencies and building, the other for actually running your app.

The result will be an extremely small dockerized version of your app (hopefully) fit for production.

⁠Reason for creating this

Most NodeJS projects require the same common things for successful install and build. Most NodeJS developers don't have the time to spend putting together a clean Alpine build. This is to save myself and others the headache of digging up their specific projects build dependencies and produce a nice minimal Alpine image to brag about to all their friends.

⁠Usage

⁠Simplest full build

docker run --privileged --rm --name build_web_proxy
-v "/path/to/project/src":/app
-v /var/run/docker.sock:/var/run/docker.sock
stevenaldinger/alpine-nodejs-dev:latest

⁠Simplest build with private modules

docker run --privileged --rm --name build_web_proxy
-e NPM_TOKEN='0a0b00cd-1a2b-0000-0000-0000000000'
-v "/path/to/project/src":/app
-v /var/run/docker.sock:/var/run/docker.sock
stevenaldinger/alpine-nodejs-dev:latest

⁠With custom entrypoint

docker run -it --rm --name custom_entry
-e NPM_TOKEN='0a0b00cd-1a2b-0000-0000-0000000000'
-v "$(pwd)/ui":'/app'
-v "$(pwd)/my_entrypoint.sh":'/usr/bin/custom_entrypoint'
stevenaldinger/alpine-nodejs-dev:latest

⁠With most options

docker run --privileged --rm --name build_app
-e APP_SRC=/app
-e APP_NAME='my app name'
-e BUILD_SCRIPT='build'
-e DOCKER_CMD='node index'
-e FORCE_NPM_INSTALL='false'
-e NPM_TOKEN='0a0b00cd-1a2b-0000-0000-0000000000'
-e NODE_SASS_FIX='true'
-v "/path/to/project/src":/app
-v /var/run/docker.sock:/var/run/docker.sock
stevenaldinger/alpine-nodejs-dev:

⁠Configuration

# ============================== CONFIG OPTIONS ============================== #
#  Environment Variable |   Default    | Required |      Description           #
# ---------------------------------------------------------------------------- #
#   APP_SRC             |    "/app"    |    No    | Mounted volume, expected   #
#                       |              |          | to have a package.json     #
# ---------------------------------------------------------------------------- #
#   APP_NAME            |from pkg.json |    No    | Name of build subdir       #
# ---------------------------------------------------------------------------- #
#   BUILD_SCRIPT        |   "build"    |    No    | Set npm run build script   #
# ---------------------------------------------------------------------------- #
#   COPY_DIR            |     "."      |    No    | Specific dir to copy to    #
#                       |              |          | docker image (ex: dist)    #
# ---------------------------------------------------------------------------- #
#   DOCKER_CMD          |npm run start |    No    | Command for docker to      #
#                       |              |          | execute on start           #
# ---------------------------------------------------------------------------- #
#   DOCKERFILE_NAME     | "D..minimal" |    No    | Name of generated          #
#                       |              |          | Dockerfile                 #
# ---------------------------------------------------------------------------- #
#   FORCE_NPM_INSTALL   |   'false'    |    No    | If not set, will skip npm  #
#                       |              |          | install if node_modules    #
#                       |              |          | dir exists and             #
#                       |              |          | package.json has no        #
#                       |              |          | detected changes           #
# ---------------------------------------------------------------------------- #
#   IMAGE_NAME          | ${APP_NAME}  |    No    | Name of built image        #
# ---------------------------------------------------------------------------- #
#   IMAGE_VERSION       |    none      |    No    | If you want a version      #
#                       |              |          | tag other than 'latest'    #
# ---------------------------------------------------------------------------- #
#   NPM_TOKEN           |    none      |    No    | NPM_TOKEN to be used for   #
#                       |              |          | accessing private modules  #
# ---------------------------------------------------------------------------- #
#   NODE_SASS_FIX       | auto-detect  |    No    | Set to "false" to opt out  #
#                       |              |          | of node-sass fix (v4.5.3)  #
# ============================ END CONFIG OPTIONS ============================ #

⁠Base

Based on mhart/alpine-node⁠, extended with glibc compatibility.

⁠Builder Image

The builder image has these NodeJS modules:

  • babel-cli
  • babel-core
  • babel-runtime
  • better-npm-run
  • node-gyp
  • nodemon
  • rimraf
  • webpack
  • yarn

And these Alpine packages:

  • alpine-sdk
  • autoconf
  • automake
  • bash
  • build-base
  • cmake
  • curl
  • curl-dev
  • docker
  • gcc
  • git
  • envsubst
  • libc-dev
  • libc6-compat
  • libcurl
  • libevent
  • libevent-dev
  • libjpeg-turbo
  • libjpeg-turbo-dev
  • libpng
  • libpng-dev
  • libtool
  • linux-headers
  • make
  • nasm
  • ncurses
  • ncurses-dev
  • python-dev
⁠Minimal Image

The minimal image contains only(ish) node, npm, and the libc6-compat package.

Tag summary

Content type

Image

Digest

Size

182.5 MB

Last updated

about 9 years ago

docker pull stevenaldinger/alpine-nodejs-dev