Giter VIP home page Giter VIP logo

alpine-node's Introduction

Minimal Node.js Docker Images (18MB, or 6.6MB compressed)

Versions v5.0.0, v4.2.1, v0.12.7, v0.10.40, and io.js – 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>):

  • Full install built with npm:
    • latest, 5, 5.0, 5.0.0 – 35.21 MB (npm 3.3.10)
    • 4, 4.2, 4.2.1 – 35.02 MB (npm 2.14.8)
    • 3, 3.3, 3.3.1 – 34.3 MB (npm 2.14.3)
    • 2, 2.5, 2.5.0 - 33.97 MB (npm 2.13.2)
    • 1, 1.8, 1.8.4 - 32.93 MB (npm 2.9.0)
    • 0.12, 0.12.7 – 32.26 MB (npm 2.14.5)
    • 0.10, 0.10.40 – 27.62 MB (npm 2.14.5)
  • Base install with node built as a static binary with no npm:
    • base, base-5, base-5.0, base-5.0.0 – 25.25 MB
    • base-4, base-4.2, base-4.2.1 – 25.04 MB
    • base-3, base-3.3, base-3.3.1 – 24.52 MB
    • base-2, base-2.5, base-2.5.0 - 24.12 MB
    • base-1, base-1.8, base-1.8.4 - 23.91 MB
    • base-0.12, base-0.12.7 – 22.3 MB
    • base-0.10, base-0.10.40 – 18.5 MB

Example

$ docker run mhart/alpine-node node --version
v5.0.0

$ docker run mhart/alpine-node:4 node --version
v4.2.1

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

$ docker run mhart/alpine-node:base node --version
v5.0.0

$ docker run mhart/alpine-node:3 iojs --version
v3.3.1

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

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
# FROM mhart/alpine-node:base-0.10
# FROM mhart/alpine-node

WORKDIR /src
ADD . .

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

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

# If you had native dependencies you can now remove build tools
# RUN apk del make gcc g++ python && \
#   rm -rf /tmp/* /var/cache/apk/* /root/.npm /root/.node-gyp

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

Caveats

As Alpine Linux uses musl, you may run into some issues with environments expecting glibc-like behaviour (for example, Kubernetes). Some of these issues are documented here:

Inspired by:

alpine-node's People

Contributors

mhart avatar

Watchers

 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.