Sign inSign up
node-pnpm logo

ymnik13/node-pnpm

By ymnik13

•Updated 2 days ago

Image
0

1.1K

ymnik13/node-pnpm repository overview

⁠ymnik13/node-pnpm

Reusable Node.js LTS base images with pinned pnpm and npm, native build tools for development, and production runtimes for Node.js applications. Suitable for Next.js, Vite, APIs, workers, and other Node.js projects.

Docker Hub⁠ · Published tags⁠

⁠Tags

One image per Node.js major and purpose. Each tag includes linux/amd64 and linux/arm64; Docker selects the architecture automatically. These are Linux containers, also usable through Docker Desktop on macOS and Windows.

Node majorCurrent Node versionProductionDevelopment / buildProduction + PostgreSQL 17 clients
2424.22.32424-dev24-pg17
2222.23.52222-dev22-pg17
2626.13.12626-dev26-pg17

For example: ymnik13/node-pnpm:24-dev. Tags stay the same when a Node patch or base package is updated. Exact versions are listed here, locked in versions.json, and recorded in image metadata. There are no patch, date, OS, architecture, or release-suffix tags. Production uses the plain major tag; no extra -prod alias is needed. Use docker pull or docker build --pull to receive an updated image within the selected major.

⁠Included tools

ComponentRuntimeDevelopmentRuntime + PG17
Node.js LTS, pnpm 11.28.12, npm 11.21.2YesYesYes
CA certificates, libstdc++, tiniYesYesYes
Non-root node user, UID/GID 1000:1000YesYesYes
C/C++ compiler, make, Python 3, pkg-config—Yes—
Git, SSH client, bash, curl, jq, procps—YesSSH client and curl
pg_dump, pg_restore, psql 17.x, util-linux——Yes

The working directory is /app. Runtime images set NODE_ENV=production; development images set NODE_ENV=development. tini forwards signals and reaps child processes. The default command is node; applications supply their own CMD. The base image does not install dependencies or run migrations at startup.

Frameworks and application tools stay in your project's lockfile: Next.js, React, TypeScript, ESLint, Prettier, Vitest, Playwright, database libraries, sharp, and other application dependencies are not installed globally. Run your project scripts or use pnpm exec. Playwright browsers belong in a separate test image matching the project's Playwright version.

⁠Quick start

# Check the runtime.
docker run --rm ymnik13/node-pnpm:24 node --version

# Check the development package manager.
docker run --rm ymnik13/node-pnpm:24-dev pnpm --version

# Optional PostgreSQL client runtime; no PostgreSQL server is included.
docker run --rm ymnik13/node-pnpm:24-pg17 pg_dump --version

⁠Next.js: development and production

This multi-stage Dockerfile uses the development image for dependency installation and compilation, then copies Next.js standalone output into the production image. Set output: 'standalone' in your Next.js configuration.

The example assumes pnpm-workspace.yaml and public/ exist. Adjust the COPY instructions if your project does not use them; monorepos may also require changes to standalone output paths and outputFileTracingRoot.

# syntax=docker/dockerfile:1.7
# Canonical major tags; exact versions are recorded in versions.json and image metadata.
ARG DEV_IMAGE=ymnik13/node-pnpm:24-dev
ARG RUNTIME_IMAGE=ymnik13/node-pnpm:24
FROM ${DEV_IMAGE} AS deps
ARG TARGETARCH
ARG CACHE_VARIANT=alpine
COPY --chown=node:node package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN --mount=type=cache,id=myapp-pnpm11-${CACHE_VARIANT}-${TARGETARCH},target=/pnpm/store,uid=1000,gid=1000 \
    pnpm install --frozen-lockfile --store-dir=/pnpm/store --package-import-method=copy

FROM deps AS dev
RUN mkdir -p /app/.next/cache
COPY --chown=node:node . .
ENV HOSTNAME=0.0.0.0
CMD ["pnpm", "dev"]

FROM deps AS build
ENV NODE_ENV=production
ARG TARGETARCH
ARG CACHE_VARIANT=alpine
COPY --chown=node:node . .
RUN mkdir -p /app/.next/cache
RUN --mount=type=cache,id=myapp-next-${CACHE_VARIANT}-${TARGETARCH},target=/app/.next/cache,uid=1000,gid=1000 \
    pnpm build

FROM ${RUNTIME_IMAGE} AS production
ENV HOSTNAME=0.0.0.0 PORT=3000
COPY --from=build --chown=node:node /app/.next/standalone ./
COPY --from=build --chown=node:node /app/.next/static ./.next/static
COPY --from=build --chown=node:node /app/public ./public
EXPOSE 3000
CMD ["node", "server.js"]

Build the desired target:

docker build --target dev -t my-app:dev .
docker build --target production -t my-app:production .

For other Node.js applications, copy the compiled application and its required production dependencies into the runtime stage, then set the appropriate command. Keep Node major, C library, and architecture compatible across build and runtime.

⁠Local development

Keep dependencies and build output in Linux volumes so host node_modules do not replace container dependencies. For example:

services:
  app:
    build:
      context: .
      target: dev
    ports: ["127.0.0.1:10201:3000"]
    volumes:
      - .:/app
      - node_modules:/app/node_modules
      - next_cache:/app/.next
      - pnpm_store:/pnpm/store
    command: [pnpm, dev]
volumes:
  node_modules:
  next_cache:
  pnpm_store:

After changing the lockfile, update the dependency volume explicitly:

docker compose run --rm app pnpm install --frozen-lockfile --store-dir=/pnpm/store

Use fresh dependency/build volumes when switching Node major, distribution, or architecture. Bind-mounted directories must be writable by UID 1000; changing user: alone does not change file ownership. The image does not recursively change ownership of your source files at startup.

⁠Dependency and build caching

  • BuildKit cache mounts preserve the pnpm store at /pnpm/store and Next.js build data at /app/.next/cache between builds.
  • Use project-specific cache IDs, separated by distribution and architecture. Share writable caches only between mutually trusted builds.
  • Copy manifests and the lockfile before application sources so source edits do not invalidate the dependency installation layer.
  • Development images include native build tools and local Node headers; npm_config_nodedir=/usr/local avoids downloading headers for node-gyp.
  • npm is available for projects using npm ci; those projects should use their own lockfile and npm cache configuration.

The pnpm wrapper uses --pm-on-fail=ignore to keep the image's reviewed pnpm version instead of silently downloading another version from packageManager. Project policies such as allowBuilds, minimumReleaseAge, and trustPolicy remain under the project's control. The base does not enable all dependency build scripts or rewrite your lockfile.

⁠Security and compatibility

  • Official Node.js LTS inputs are pinned by exact patch and manifest digest. pnpm and npm downloads use exact versions and SHA512 integrity checks.
  • Release builds refresh packages from stable OS repositories and run smoke tests, including a real node-gyp/N-API compile-and-load test in development.
  • Every published architecture is scanned before publication. HIGH or CRITICAL findings, including vendor-unfixed findings, block the release. Scanner and database failures also block publication.
  • New builds are uploaded by digest without public tags, then scanned for both platforms. The advertised major tags move only after every selected image passes. Temporary architecture, patch, and release tags are not published.
  • All 18 platform images behind the nine published tags passed the release scan with 0 HIGH/CRITICAL findings. Anonymous registry checks verified both platforms, non-root configuration, content digests, and matching scanned image identities.

Alpine uses musl, so validate native dependencies on each target architecture. The official Node Docker documentation⁠ classifies upstream Linux/amd64 musl builds as Experimental tier. Passing tests and a clean vulnerability scan do not extend upstream platform support guarantees.

The selected base OS is Alpine 3.23 for all majors. The publisher maintains one base per major, rather than a separate tag matrix for multiple distributions.

Scan results are a point-in-time check, not a guarantee against future issues. Review and rebuild base images regularly, and scan the final application image: its own dependencies and application code are outside the scope of this base.

Tag summary

Content type

Image

Digest

sha256:46e6cdc52…

Size

76.2 MB

Last updated

2 days ago

docker pull ymnik13/node-pnpm:26-pg17