fix(docker): upgrade OpenSCAD to 2024.11 to fix CGAL intersection bug

The old OpenSCAD 2021.01 from Debian repos has CGAL bugs that cause
intersection operations to fail with "assertion violation" errors.

This was breaking the 3D abacus creator which uses intersection()
to create the mirrored book-fold design.

Changes:
- Add openscad-builder stage to download and extract OpenSCAD 2024.11.18 AppImage
- Remove old openscad from apt packages
- Add Qt5 and graphics runtime dependencies for new OpenSCAD
- Copy new OpenSCAD binary and libraries to runner stage
- Set LD_LIBRARY_PATH for OpenSCAD libraries

Testing on prod showed "CGAL ERROR: assertion violation" in intersection
operations, producing incomplete 1.8K STL files instead of multi-MB files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock
2025-11-04 19:48:49 -06:00
parent 2df4423684
commit e1bcd24169

View File

@@ -107,23 +107,60 @@ RUN mkdir -p /bosl2 && \
find . -type f ! -name "*.scad" -delete && \
find . -type d -empty -delete
# OpenSCAD builder stage - download and prepare newer OpenSCAD binary
FROM node:18-slim AS openscad-builder
RUN apt-get update && apt-get install -y --no-install-recommends \
wget \
ca-certificates \
file \
&& rm -rf /var/lib/apt/lists/*
# Download latest OpenSCAD AppImage and extract it
# Using 2024.11 which has CGAL fixes for intersection operations
RUN wget -q https://files.openscad.org/OpenSCAD-2024.11.18-x86_64.AppImage -O /tmp/openscad.AppImage && \
chmod +x /tmp/openscad.AppImage && \
cd /tmp && \
./openscad.AppImage --appimage-extract && \
mv squashfs-root/usr/bin/openscad /usr/local/bin/openscad && \
mv squashfs-root/usr/lib /usr/local/openscad-lib && \
chmod +x /usr/local/bin/openscad
# Production image - Using Debian base for OpenSCAD availability
FROM node:18-slim AS runner
WORKDIR /app
# Install ONLY runtime dependencies (no build tools)
# Using Debian because OpenSCAD is not available in Alpine repos
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
python3-pip \
qpdf \
openscad \
ca-certificates \
libgomp1 \
libglu1-mesa \
libglew2.2 \
libfreetype6 \
libfontconfig1 \
libharfbuzz0b \
libxml2 \
libzip4 \
libdouble-conversion3 \
libqt5core5a \
libqt5gui5 \
libqt5widgets5 \
libqt5concurrent5 \
libqt5multimedia5 \
libqt5network5 \
libqt5dbus5 \
&& rm -rf /var/lib/apt/lists/*
# Copy typst binary from typst-builder stage
COPY --from=typst-builder /usr/local/bin/typst /usr/local/bin/typst
# Copy newer OpenSCAD from openscad-builder stage
COPY --from=openscad-builder /usr/local/bin/openscad /usr/local/bin/openscad
COPY --from=openscad-builder /usr/local/openscad-lib /usr/local/openscad-lib
ENV LD_LIBRARY_PATH=/usr/local/openscad-lib:$LD_LIBRARY_PATH
# Copy minimized BOSL2 library from bosl2-builder stage
RUN mkdir -p /usr/share/openscad/libraries
COPY --from=bosl2-builder /bosl2 /usr/share/openscad/libraries/BOSL2