-
Notifications
You must be signed in to change notification settings - Fork 15
multi-stage build #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
flaviut
wants to merge
2
commits into
openscad:main
Choose a base branch
from
flaviut:multi-stage-build
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,91 +1,248 @@ | ||
| # | ||
| # Build: docker build --progress=plain --load -t openscad/appimage-x86_64-base:latest . | ||
| # | ||
| FROM ubuntu:22.04 | ||
| # ----------------------------------------------------------------------------- | ||
| # Stage 1: Base image (Minimal) | ||
| # ----------------------------------------------------------------------------- | ||
| FROM ubuntu:24.04 AS base | ||
| ENV DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| ARG GITHUB_USER=openscad | ||
| ARG GITHUB_REPO=openscad | ||
| ARG BRANCH=master | ||
| # Install only the absolute bare minimum build tools used by almost everyone | ||
| # (wget/curl/ca-certificates for downloading, build-essential for compiling) | ||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends \ | ||
| build-essential \ | ||
| ca-certificates \ | ||
| cmake \ | ||
| curl \ | ||
| git \ | ||
| gnupg \ | ||
| ninja-build \ | ||
| wget \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| ENV DEBIAN_FRONTEND=noninteractive | ||
| # ----------------------------------------------------------------------------- | ||
| # Stage 2: Lib3MF | ||
| # ----------------------------------------------------------------------------- | ||
| FROM base AS lib3mf-builder | ||
|
|
||
| RUN \ | ||
| apt-get update && \ | ||
| apt-get upgrade -y && \ | ||
| apt-get install -y --no-install-recommends \ | ||
| software-properties-common \ | ||
| apt-transport-https \ | ||
| ca-certificates \ | ||
| openssh-client \ | ||
| libsqlite3-dev \ | ||
| lsb-release \ | ||
| liblzma-dev \ | ||
| libssl-dev \ | ||
| libbz2-dev \ | ||
| appstream \ | ||
| apt-utils \ | ||
| unzip \ | ||
| gnupg \ | ||
| file \ | ||
| ncat \ | ||
| wget \ | ||
| git | ||
| # Install Lib3MF specific dependencies | ||
| # uuid-dev, libssl-dev etc. are required for Lib3MF | ||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends \ | ||
| uuid-dev \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN \ | ||
| sed -ie 's/^#\s*\(.*universe\)$/\1/' /etc/apt/sources.list && \ | ||
| echo "deb https://download.opensuse.org/repositories/home:/t-paul:/lib3mf/xUbuntu_22.04/ ./" >> /etc/apt/sources.list && \ | ||
| echo "deb https://download.opensuse.org/repositories/home:/t-paul:/cgal/xUbuntu_22.04/ ./" >> /etc/apt/sources.list && \ | ||
| grep -v "^#" /etc/apt/sources.list && \ | ||
| wget -qO - https://files.openscad.org/OBS-Repository-Key.pub | apt-key add - && \ | ||
| apt-get update && \ | ||
| apt-get upgrade -y | ||
| # 1.8.1 | ||
| ARG LIB3MF_COMMIT=ff914b9fae76cd6a365952728f44f8d79a9f8f75 | ||
|
|
||
| WORKDIR /openscad | ||
| WORKDIR /tmp/build | ||
|
|
||
| # Invalidate docker cache if the branch changes | ||
| ADD https://api.github.com/repos/${GITHUB_USER}/${GITHUB_REPO}/git/refs/heads/${BRANCH} version.json | ||
| RUN wget -q https://github.com/3MFConsortium/lib3mf/archive/${LIB3MF_COMMIT}.tar.gz -O lib3mf.tar.gz && \ | ||
| mkdir lib3mf && \ | ||
| tar -xzf lib3mf.tar.gz -C lib3mf --strip-components=1 && \ | ||
| rm lib3mf.tar.gz | ||
|
|
||
| RUN \ | ||
| cat version.json && rm -f version.json && \ | ||
| git clone "https://github.com/${GITHUB_USER}/${GITHUB_REPO}" . && \ | ||
| git checkout "${BRANCH}" && \ | ||
| git rev-parse --abbrev-ref HEAD && \ | ||
| git log -n8 --pretty=tformat:"%h %ai (%aN) %s" | ||
| WORKDIR /tmp/build/lib3mf/build | ||
|
|
||
| RUN \ | ||
| bash ./scripts/uni-get-dependencies.sh && \ | ||
| bash ./scripts/check-dependencies.sh && \ | ||
| (apt-get install -y lib3mf-dev python3-dev nettle-dev || /bin/true) && \ | ||
| apt-get clean | ||
| RUN cmake .. \ | ||
| -GNinja \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DLIB3MF_TESTS=OFF \ | ||
| -DUSE_INCLUDED_SSL=OFF \ | ||
| -DCMAKE_INSTALL_PREFIX=/inst \ | ||
| -DCMAKE_INSTALL_LIBDIR=lib && \ | ||
| cmake --build . --config Release && \ | ||
| cmake --install . | ||
|
|
||
| # ----------------------------------------------------------------------------- | ||
| # Stage 3: CGAL | ||
| # ----------------------------------------------------------------------------- | ||
| FROM base AS cgal-builder | ||
|
|
||
| # Install CGAL specific dependencies | ||
| # CGAL often needs GMP/MPFR (though sometimes header-only, full builds need them) | ||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends \ | ||
| libgmp-dev \ | ||
| libboost-dev \ | ||
| libmpfr-dev \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # v5.6.3 | ||
| ARG CGAL_COMMIT=3654f780ae0c64675cabaef0e5ddaf904c48b4b7 | ||
|
|
||
| WORKDIR /tmp/build | ||
|
|
||
| RUN wget -q https://github.com/CGAL/cgal/archive/${CGAL_COMMIT}.tar.gz -O cgal.tar.gz && \ | ||
| mkdir cgal && \ | ||
| tar -xzf cgal.tar.gz -C cgal --strip-components=1 && \ | ||
| rm cgal.tar.gz | ||
|
|
||
| WORKDIR /tmp/build/cgal/build | ||
|
|
||
| RUN cmake .. \ | ||
| -GNinja \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DCGAL_HEADER_ONLY=OFF \ | ||
| -DBUILD_TESTING=OFF \ | ||
| -DBUILD_DOC=OFF \ | ||
| -DCMAKE_INSTALL_PREFIX=/inst \ | ||
| -DCMAKE_INSTALL_LIBDIR=lib && \ | ||
| cmake --build . --config Release && \ | ||
| cmake --install . | ||
|
|
||
| # ----------------------------------------------------------------------------- | ||
| # Stage 4: QScintilla | ||
| # ----------------------------------------------------------------------------- | ||
| FROM base AS qscintilla-builder | ||
|
|
||
| # Install Qt5 dependencies specifically for QScintilla | ||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends \ | ||
| qt5-qmake \ | ||
| qtbase5-dev \ | ||
| libqt5svg5-dev \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| WORKDIR /build | ||
| RUN wget -q https://www.riverbankcomputing.com/static/Downloads/QScintilla/2.14.1/QScintilla_src-2.14.1.tar.gz && \ | ||
| tar xvf QScintilla_src-2.14.1.tar.gz | ||
|
|
||
| WORKDIR /build/QScintilla_src-2.14.1/src | ||
| RUN qmake && \ | ||
| make -j$(nproc) && \ | ||
| make install INSTALL_ROOT=/inst | ||
|
|
||
| # ----------------------------------------------------------------------------- | ||
| # Stage 5: AppImage Tooling (LinuxDeploy) | ||
| # ----------------------------------------------------------------------------- | ||
| FROM base AS deploy-tools | ||
|
|
||
| # Dependencies for extracting AppImages and running linuxdeploy scripts | ||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends \ | ||
| file \ | ||
| unzip \ | ||
| python3-dev \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| WORKDIR /appimage | ||
|
|
||
| RUN wget -q https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage && \ | ||
| wget -q https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage && \ | ||
| wget -q https://github.com/t-paul/linuxdeploy-plugin-python/archive/refs/heads/master.zip -O linuxdeploy-plugin-python.zip && \ | ||
| wget -q https://raw.githubusercontent.com/linuxdeploy/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh | ||
|
|
||
| RUN chmod +x linuxdeploy*.AppImage *.sh && \ | ||
| ./linuxdeploy-x86_64.AppImage --appimage-extract && \ | ||
| ./linuxdeploy-plugin-qt-x86_64.AppImage --appimage-extract && \ | ||
| mkdir -p usr/bin/share && \ | ||
| mv -iv squashfs-root/usr/bin/* usr/bin && \ | ||
| mv -iv squashfs-root/plugins . && \ | ||
| rm -rf squashfs-root && \ | ||
| unzip -p linuxdeploy-plugin-python.zip linuxdeploy-plugin-python-master/linuxdeploy-plugin-python.sh > usr/bin/linuxdeploy-plugin-python.sh && \ | ||
| unzip -p linuxdeploy-plugin-python.zip linuxdeploy-plugin-python-master/share/sitecustomize.py > usr/bin/sitecustomize.py && \ | ||
| chmod 755 /appimage/usr/bin/linuxdeploy-plugin-python.sh && \ | ||
| rm -rf *.AppImage *.zip | ||
|
|
||
| # ----------------------------------------------------------------------------- | ||
| # Stage 6: Final Assembly & OpenSCAD Build Prep | ||
| # ----------------------------------------------------------------------------- | ||
| FROM base AS openscad-appimage-x86_64-base | ||
|
|
||
| # Install Runtime/Link-time dependencies required for the final OpenSCAD aggregation | ||
| # These are things that OpenSCAD itself needs to compile or run the dependency scripts. | ||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends \ | ||
| appstream \ | ||
| apt-transport-https \ | ||
| apt-utils \ | ||
| file \ | ||
| libbz2-dev \ | ||
| liblzma-dev \ | ||
| libqt5svg5-dev \ | ||
| libsqlite3-dev \ | ||
| libssl-dev \ | ||
| libgmp-dev \ | ||
| lsb-release \ | ||
| ncat \ | ||
| nettle-dev \ | ||
| openssh-client \ | ||
| python3-dev \ | ||
| qt5-qmake \ | ||
| qtbase5-dev \ | ||
| software-properties-common \ | ||
| unzip \ | ||
| uuid-dev \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| WORKDIR /openscad | ||
|
|
||
| # 2025-12-23 | ||
| ARG OPENSCAD_COMMIT=cfdd775c439094698f1c6e5595b7574f636af4da | ||
|
|
||
| RUN curl -L "https://github.com/openscad/openscad/archive/${OPENSCAD_COMMIT}.tar.gz" | tar -xz --strip-components=1 && \ | ||
| bash ./scripts/uni-get-dependencies.sh && \ | ||
| apt-get clean && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| COPY --from=lib3mf-builder /inst /usr/ | ||
| COPY --from=cgal-builder /inst /usr/ | ||
| COPY --from=qscintilla-builder /inst /usr/ | ||
| RUN ldconfig | ||
|
|
||
| COPY --from=deploy-tools /appimage /appimage | ||
|
|
||
| RUN bash ./scripts/check-dependencies.sh && \ | ||
| find . -maxdepth 1 -mindepth 1 -exec rm -rf {} + | ||
|
|
||
| # ----------------------------------------------------------------------------- | ||
| # Stage 6: Final Build | ||
| # ----------------------------------------------------------------------------- | ||
| FROM openscad-appimage-x86_64-base | ||
|
|
||
| WORKDIR /openscad | ||
|
|
||
| ARG OPENSCAD_COMMIT=cfdd775c439094698f1c6e5595b7574f636af4da | ||
| ARG SNAPSHOT=ON | ||
| ARG JOBS=4 | ||
|
|
||
| RUN \ | ||
| rm -rf /openscad && \ | ||
| wget -q https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage && \ | ||
| wget -q https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage && \ | ||
| wget -q https://github.com/t-paul/linuxdeploy-plugin-python/archive/refs/heads/master.zip -O linuxdeploy-plugin-python.zip && \ | ||
| wget -q https://raw.githubusercontent.com/linuxdeploy/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh | ||
| git clone "https://github.com/openscad/openscad" . && \ | ||
| git checkout "${OPENSCAD_COMMIT}" && \ | ||
| git submodule update --init --recursive && \ | ||
| git log -n8 --pretty=tformat:"%h %ai (%aN) %s" | ||
|
|
||
| RUN \ | ||
| chmod +x linuxdeploy*.AppImage *.sh && \ | ||
| ./linuxdeploy-x86_64.AppImage --appimage-extract && \ | ||
| ./linuxdeploy-plugin-qt-x86_64.AppImage --appimage-extract && \ | ||
| mkdir -p usr/bin/share && \ | ||
| mv -iv squashfs-root/usr/bin/* usr/bin && \ | ||
| mv -iv squashfs-root/plugins . && \ | ||
| rm -rf squashfs-root && \ | ||
| unzip -p linuxdeploy-plugin-python.zip linuxdeploy-plugin-python-master/linuxdeploy-plugin-python.sh > usr/bin/linuxdeploy-plugin-python.sh && \ | ||
| unzip -p linuxdeploy-plugin-python.zip linuxdeploy-plugin-python-master/share/sitecustomize.py > usr/bin/sitecustomize.py && \ | ||
| chmod 755 /appimage/usr/bin/linuxdeploy-plugin-python.sh && \ | ||
| rm -rf squashfs-root && \ | ||
| rm -rf *.AppImage && \ | ||
| find /appimage | ||
| export OPENSCAD_VERSION="$(date +%Y.%m.%d).ai" && \ | ||
| export OPENSCAD_COMMIT=$(/bin/"$COMMIT" && git log -1 --pretty=format:%h || echo "") && \ | ||
| mkdir build && \ | ||
| cd build && \ | ||
| cmake .. \ | ||
| -DOPENSCAD_VERSION="$OPENSCAD_VERSION" \ | ||
| -DOPENSCAD_COMMIT="$OPENSCAD_COMMIT" \ | ||
| -DCMAKE_INSTALL_PREFIX=/usr \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DUSE_BUILTIN_OPENCSG=ON \ | ||
| -DMANIFOLD_PYBIND=OFF \ | ||
| -DMANIFOLD_TEST=OFF \ | ||
| -DENABLE_PYTHON=ON \ | ||
| -DENABLE_TESTS=OFF \ | ||
| -DEXPERIMENTAL=${SNAPSHOT} \ | ||
| -DSNAPSHOT=${SNAPSHOT} \ | ||
| && \ | ||
| make -j"$JOBS" && \ | ||
| make install DESTDIR=../AppDir | ||
|
|
||
| RUN \ | ||
| dpkg --purge $(dpkg -l 'libqscintilla2-qt5*' | grep ^ii | awk '{ print $2 }') && \ | ||
| wget -q https://www.riverbankcomputing.com/static/Downloads/QScintilla/2.14.1/QScintilla_src-2.14.1.tar.gz && \ | ||
| tar xvf QScintilla_src-2.14.1.tar.gz && \ | ||
| cd QScintilla_src-2.14.1/src && \ | ||
| qmake && \ | ||
| make -j2 && make install | ||
| export PATH=/appimage/usr/bin:"$PATH" && \ | ||
| mv -iv AppDir/usr/share/applications/openscad.desktop AppDir/usr/share/applications/org.openscad.OpenSCAD.desktop && \ | ||
| sed -i -e 's/openscad.desktop/org.openscad.OpenSCAD.desktop/' AppDir/usr/share/metainfo/org.openscad.OpenSCAD.appdata.xml && \ | ||
| sed -i -e '/<content_rating/d' AppDir/usr/share/metainfo/org.openscad.OpenSCAD.appdata.xml && \ | ||
| DEBUG=1 \ | ||
| EXTRA_QT_MODULES=svg \ | ||
| LINUXDEPLOY_OUTPUT_VERSION="${OPENSCAD_VERSION:-$(date +%Y.%m.%d).ai}" \ | ||
| PYTHON_VERSION=$(python3 -c "import sys; v=sys.version_info; print(f'{v.major}.{v.minor}.{v.micro}')") \ | ||
| linuxdeploy --plugin python --plugin qt --output appimage --appdir AppDir && \ | ||
| mkdir -p out && \ | ||
| cp -iv OpenSCAD*.AppImage out/ | ||
|
|
||
| ENTRYPOINT [ "tar", "--create", "-C", "/openscad/out", "." ] | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this was built as part of the main openscad repo, I would change this to
that means that
openscad-appimage-x86_64-basewould only be rebuilt if either of those two files changed.