Dockerfile60 lines · 1245 chars ARG BUILD_FROM_SOURCE=0
FROM node:slim AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build tools only when requested
RUN set -eux; \
if [ "${BUILD_FROM_SOURCE:-0}" = "1" ]; then \
apt-get update; \
apt-get install -y --no-install-recommends \
build-essential \
python3 \
python3-dev \
ca-certificates \
curl \
git \
pkg-config \
libssl-dev \
zlib1g-dev \
libtool \
automake \
bzip2 \
xz-utils; \
rm -rf /var/lib/apt/lists/*; \
else \
echo "Skipping heavy build dependencies"; \
fi
WORKDIR /work
COPY . .
ENV PYTHON=python3
# Build from source only if requested
RUN if [ "${BUILD_FROM_SOURCE:-0}" = "1" ]; then \
./configure && make -j4 && make install; \
else \
echo "Build from source is disabled"; \
fi
FROM node:slim
ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
; \
rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local /usr/local
WORKDIR /work
CMD ["node", "-v"]