GithubHelp home page GithubHelp logo

alpine-node's Introduction

Minimal Node.js Docker Images

Versions v8.2.1, v6.11.2, v4.8.4, v0.12.18 and v0.10.48 – built on Alpine Linux.

All versions use the one mhart/alpine-node repository, but each version aligns with the following tags (ie, mhart/alpine-node:<tag>). The sizes are for the unpacked images as reported by Docker – compressed sizes are about 1/3 of these:

  • Full install built with npm and yarn:
    • latest, 8, 8.2, 8.2.1 – 63.3 MB (npm 5.3.0, yarn 0.27.5)
  • Full install build with npm:
    • 6, 6.11, 6.11.2 – 48.7 MB (npm 3.10.10)
    • 4, 4.8, 4.8.4 – 35.2 MB (npm 2.15.12)
    • 0.12, 0.12.18 – 33.36 MB (npm 2.15.11)
    • 0.10, 0.10.48 – 28.16 MB (npm 2.15.11)
  • Base install with node built as a static binary with no npm or yarn:
    • base, base-8, base-8.2, base-8.2.1 – 43.4 MB
    • base-6, base-6.11, base-6.11.1 – 37.2 MB
    • base-4, base-4.8, base-4.8.4 – 26.6 MB
    • base-0.12, base-0.12.18 – 24.72 MB
    • base-0.10, base-0.10.48 – 18.22 MB

Major io.js versions are tagged too.

Examples

$ docker run mhart/alpine-node node --version
v8.2.1

$ docker run mhart/alpine-node npm --version
5.3.0

$ docker run mhart/alpine-node yarn --version
0.27.5

$ docker run mhart/alpine-node:6 node --version
v6.11.2

$ docker run mhart/alpine-node:base node --version
v8.2.1

$ docker run mhart/alpine-node:base-0.10 node --version
v0.10.48

Example Dockerfile for your own Node.js project

If you don't have any native dependencies, ie only depend on pure-JS npm modules, then my suggestion is to run npm install locally before running docker build (and make sure node_modules isn't in your .dockerignore) – then you don't need an npm install step in your Dockerfile and you don't need npm installed in your Docker image – so you can use one of the smaller base* images.

FROM mhart/alpine-node:base-6
# FROM mhart/alpine-node:6

WORKDIR /src
ADD . .

# If you have native dependencies, you'll need extra tools
# RUN apk add --no-cache make gcc g++ python

# If you need npm, don't use a base tag
# RUN npm install

EXPOSE 3000
CMD ["node", "index.js"]

Caveats

As Alpine Linux uses musl, you may run into some issues with environments expecting glibc-like behavior – especially if you try to use binaries compiled with glibc. You should recompile these binaries to use musl (compiling on Alpine is probably the easiest way to do this).

Inspired by:

alpine-node's People

Contributors

jakxz avatar mhart avatar rudijs avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.