Sign inSign up

mxmd/node

By mxmd

Updated 4 days ago

Image
0

10K+

mxmd/node repository overview

cross platform alpine-based Node.js 14 - 22 images

Front-End Asset Building

Using Docker Node.js Images from Docker Hub

This repository builds and publishes Node.js images built on top of the official Alpine-based Node.js images (node:v${VERSION}-alpine). These images are optimized for front-end asset building and compilation. These images are designed for building JavaScript, CSS, and other front-end assets, not for running Node.js applications in production. Our images are compatible with both ARM64 and x86_64 host architectures and integrate seamlessly with modern build tools like Webpack, Vite, Rollup, and other front-end bundlers.

Pulling our Node.js Docker Images

To get a specific version of our Node.js image, use:

docker pull mxmd/node:v<VERSION>

Where:

  • <VERSION> is the desired Node.js major version (e.g., v14, v16, v18, v20, v22).
  • For images with Chrome/Puppeteer support, append -full to the version (e.g., v18-full).

For example, to pull the Node.js 18 image:

docker pull mxmd/node:v18

Or to pull the Node.js 18 image with Chrome/Puppeteer support:

docker pull mxmd/node:v18-full

Available versions of our images along with their Docker Hub links:

Base versions:

Chrome-enabled versions:

Gulp-specific versions:

Image Types

Standard Images (e.g., 18, 20, 22): Include Node.js with essential build tools and dependencies for front-end asset compilation:

  • Build tools (make, gcc, g++, python3) for native module compilation
  • Image processing libraries (libpng, libjpeg-turbo, libwebp) for imagemin and asset optimization
  • Git, curl, wget, bash for package management and build scripts

Full Images (with -full suffix): Include everything from standard images plus:

  • Chromium browser for headless testing and screenshot generation during builds
  • Additional Chrome dependencies for Puppeteer-based build tasks
  • Pre-configured environment variables for Puppeteer integration

Gulp Images: Include everything from standard images plus pre-installed Gulp:

  • gulp4 variants: Pre-installed Gulp 4.0.0 for legacy projects
  • gulp5 variants: Pre-installed Gulp 5.0.0 for modern projects
  • gulp4-full and gulp5-full variants: Combine Gulp installation with Chrome/Puppeteer support
Usage with Docker Compose

You can integrate our Node.js images into your front-end build workflows. Here are several common use cases:

Basic Build Service
services:
  frontend-build:
    image: mxmd/node:v18
    container_name: frontend-builder
    working_dir: /app
    volumes:
      - .:/app
      - /app/node_modules
    environment:
      - NODE_ENV=production
      # these are CRITICAL for linux hosts
      - HOST_USER_UID=${HOST_USER_UID:-1000}
      - HOST_USER_GID=${HOST_USER_GID:-1000}
    command: yarn && yarn build
Build with Chrome/Puppeteer Testing
services:
  frontend-build-with-testing:
    image: mxmd/node:v18-full
    container_name: frontend-builder-full
    working_dir: /app
    volumes:
      - .:/app
      - /app/node_modules
    environment:
      - NODE_ENV=production
      - HOST_USER_UID=${HOST_USER_UID:-1000}
      - HOST_USER_GID=${HOST_USER_GID:-1000}
    shm_size: 1gb
    command: |
      sh -c "yarn && yarn build && yarn test:e2e"
Development with Watch Mode
services:
  dev-server:
    image: mxmd/node:v20
    container_name: dev-server
    working_dir: /app
    volumes:
      - .:/app
      - /app/node_modules
    ports:
      - "3000:3000"
      - "5173:5173"  # Vite dev server
    environment:
      - NODE_ENV=development
      - HOST_USER_UID=${HOST_USER_UID:-1000}
      - HOST_USER_GID=${HOST_USER_GID:-1000}
    command: yarn && yarn dev
Multi-Stage Build Pipeline
services:
  install-deps:
    image: mxmd/node:v18
    working_dir: /app
    volumes:
      - .:/app
      - node_modules:/app/node_modules
    environment:
      - HOST_USER_UID=${HOST_USER_UID:-1000}
      - HOST_USER_GID=${HOST_USER_GID:-1000}
    command: yarn install --frozen-lockfile

  build-assets:
    image: mxmd/node:v18
    working_dir: /app
    volumes:
      - .:/app
      - node_modules:/app/node_modules
      - build_output:/app/dist
    environment:
      - NODE_ENV=production
      - HOST_USER_UID=${HOST_USER_UID:-1000}
      - HOST_USER_GID=${HOST_USER_GID:-1000}
    command: yarn build
    depends_on:
      - install-deps

  run-tests:
    image: mxmd/node:v18-full
    working_dir: /app
    volumes:
      - .:/app
      - node_modules:/app/node_modules
    environment:
      - NODE_ENV=test
      - HOST_USER_UID=${HOST_USER_UID:-1000}
      - HOST_USER_GID=${HOST_USER_GID:-1000}
    shm_size: 1gb
    command: yarn test
    depends_on:
      - install-deps

volumes:
  node_modules:
  build_output:
Gulp-Specific Build
services:
  gulp-build:
    image: mxmd/node:v18-gulp4
    container_name: gulp-builder
    working_dir: /app
    volumes:
      - .:/app
      - /app/node_modules
    environment:
      - NODE_ENV=production
      - HOST_USER_UID=${HOST_USER_UID:-1000}
      - HOST_USER_GID=${HOST_USER_GID:-1000}
    command: |
      sh -c "npm install && gulp build"
With SSH Keys for Private Repositories
services:
  build-with-ssh:
    image: mxmd/node:v20
    working_dir: /app
    volumes:
      - .:/app
      - /app/node_modules
      - ~/.ssh:/home/node/.ssh-copy:ro  # SSH keys mounted as read-only
    environment:
      - NODE_ENV=production
      - HOST_USER_UID=${HOST_USER_UID:-1000}
      - HOST_USER_GID=${HOST_USER_GID:-1000}
    command: |
      sh -c "yarn install && yarn build"
Complete Development Environment
services:
  frontend:
    image: mxmd/node:v20-full
    container_name: frontend-dev
    working_dir: /app
    volumes:
      - .:/app
      - /app/node_modules
      - ~/.ssh:/home/node/.ssh-copy:ro
    ports:
      - "3000:3000"
      - "5173:5173"
      - "8080:8080"
    environment:
      - NODE_ENV=development
      - HOST_USER_UID=${HOST_USER_UID:-1000}
      - HOST_USER_GID=${HOST_USER_GID:-1000}
      - CHOKIDAR_USEPOLLING=true  # For file watching in containers
    shm_size: 1gb
    stdin_open: true
    tty: true
    command: bash  # Interactive shell for development

Important Notes:

  • The shm_size: 1gb is recommended for -full images when running Puppeteer/Chrome-based tests
  • SSH keys are automatically configured by the entrypoint when mounted to /home/node/.ssh-copy
  • Use CHOKIDAR_USEPOLLING=true for file watching in development containers
  • The entrypoint handles user ID/group ID mapping for proper file permissions
Required Environment Variables

Ensure these environment variables exist on your host machine:

HOST_USER_GID
HOST_USER_UID
Setting these Environment Variables

On macOS, you can set them in ~/.extra or ~/.bash_profile.

To get HOST_USER_UID:

id -u

To get HOST_USER_GID:

id -g

To set these on your host machine:

echo "export HOST_USER_GID=$(id -g)" >> ~/.bash_profile && echo "export HOST_USER_UID=$(id -u)" >> ~/.bash_profile && echo "export DOCKER_USER=$(id -u):$(id -g)" >> ~/.bash_profile

Tag summary

Content type

Image

Digest

sha256:9d1b6f9e9

Size

282.4 MB

Last updated

4 days ago

docker pull mxmd/node:v14-gulp5-full-202609111842