Dockerfile31 lines · 1050 chars FROM node:18-slim
# Build-time metadata
LABEL maintainer="ShareJS Build Agent"
# Create app directory
WORKDIR /usr/src/sharejs
# Install build tools to enable native modules and building the project
RUN set -eux; \
apt-get update && \
apt-get install -y --no-install-recommends build-essential python3 ca-certificates && \
rm -rf /var/lib/apt/lists/*
# Install dependencies and build assets without triggering prepublish scripts
# Copy only manifest files first to leverage npm install efficiently
COPY package.json Makefile ./
RUN npm install --ignore-scripts
# Copy the rest of the source code
COPY . .
# Build the project from source (produces dist/share.js and dist/share.min.js)
RUN npm run build
# Prune dev dependencies to keep the final image smaller
RUN npm prune --production
# Default command: show basic readiness and presence of dist/share.js
CMD ["sh", "-lc", "if [ -f dist/share.js ]; then echo 'ShareJS build complete: dist/share.js present'; else echo 'Build failed: dist/share.js missing'; fi; node -v; npm -v"]