Skip to content

Extending

Amnoor Brar edited this page Apr 1, 2026 · 1 revision

Icon

Extending Runtime-Node

If your application requires specific C-level system libraries (for example, libvips for image processing, or sqlite-libs for database engines) that are not included in the base Runtime-Node image, you can add them in your builder stage and copy them into the final stage of your Dockerfile.

How to add system libraries:

  1. Install the Package in the Builder Stage: Install the required package in the builder stage. For example:
    RUN apk add --no-cache [Package]
  2. Copy the Package and all it's dependencies to the Final Stage: Find the Package and Dependencies absolute path and copy it into the Final Stage, with appropriate permissions. For Example:
    # Copy the Package and all it's dependencies
    COPY --from=builder --chown=1000:1000 --chmod=550 [Package absolute path] # Or use `--chmod=770`
    COPY --from=builder --chown=1000:1000 --chmod=550 [Package Dependencies absolute path] # Or use `--chmod=770`

Dockerfile Example

# Use the same Node.js version in the builder stage as the Runtime Node's Node.js version in the final Stage
FROM node:<node_version>-alpine3.23 AS builder

WORKDIR /dist/

COPY package*.json ./

RUN npm ci --omit=dev --no-cache && \
    apk add --no-cache [Package]

COPY ./ ./

# Use the same Runtime Node's Node.js version in the final Stage as the Node.js version in the builder stage
FROM runtimenode/runtime-node:v<major>.<minor>.<patch>-node<node_version>

# Copy the Package and all it's dependencies
COPY --from=builder --chown=1000:1000 --chmod=550 [Package absolute path] # Or use `--chmod=770` if needed
COPY --from=builder --chown=1000:1000 --chmod=550 [Package Dependencies absolute path] # Or use `--chmod=770` if needed

WORKDIR /application/

COPY --from=builder --chown=1000:1000 --chmod=550 /dist/ ./

EXPOSE 5500 # Optional, if the application needs it

USER 1000:1000

ENTRYPOINT ["/usr/local/bin/node", "index.js"]