FROM node:lts-bookworm
# Install minimal system dependencies required for building and runtime
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
ca-certificates \
gnupg \
build-essential \
zip \
unzip \
openjdk-17-jre-headless \
python3 \
&& rm -rf /var/lib/apt/lists/*
# Set working directory for the build context
WORKDIR /workspace
# Copy the repository first so npm can install with access to source structure
COPY . .
# Install npm dependencies if a package.json exists
RUN if [ -f package.json ]; then \
npm ci --silent 2>/dev/null || npm install --silent; \
fi
# Prepare a simple build artifact to resemble a built distribution
# If Closure base.js exists, copy it into dist as a minimal artifact
RUN mkdir -p dist && \
if [ -f closure/goog/base.js ]; then \
cp closure/goog/base.js dist/base.js; \
fi
# If a build script is defined in package.json, try to run it (non-fatal if missing)
RUN if [ -f package.json ] && grep -q '"build"' package.json; then \
npm run build || true; \
fi
# Expose a cache directory to speed up iterative builds (mountable at runtime)
VOLUME ["/workspace/.build-cache"]
ENV BUILD_CACHE_DIR=/workspace/.build-cache
# Default command to keep the container usable for inspection or basic tasks
CMD ["bash"]