Showcase

How ambientCG builds 40,000 downloadable files with Dagu

ambientCG publishes about 2,800 CC0 materials, HDRIs and 3D models as roughly 40,000 ZIP files, all built by Dagu pipelines. The same pipelines add each new asset, rebuild the library for new releases, and run in CI as tests.

Built by ambientCG / Lennart Demes ·

All downloadable files along with preview media are built using several different Dagu pipelines…

ambientCG / Lennart Demes
downloads a month
4M+
CC0 assets
~2,800
ZIP files built by Dagu
~40,000
steps in the longest pipeline
22
How ambientCG builds its downloads. A Docker container holds Dagu and the tools its pipeline steps run: PowerShell Core, Blender and OpenUSD. The pipelines build about 40,000 ZIP files and the preview images for ambientCG.com. The same pipelines run on a workstation for new assets, on a dedicated laptop for full library rebuilds, and in GitHub Actions for pipeline tests.
The same pipelines run in all three places.

The problem

Lennart Demes started ambientCG in 2018 to publish free 3D textures. It has grown into one of the largest CC0 libraries of PBR materials, HDRIs and 3D models, with several hundred thousand unique visitors a month.

Each asset is offered in many resolutions, with ready-to-use files for common 3D programs, which adds up to about 40,000 ZIP files. Adding one asset means building all of its ZIPs, and a release with new features means rebuilding the whole library.

How it's built

Everything a build needs lives in one Docker container: Dagu, PowerShell Core for the scripts, Blender, OpenUSD and other tools.

The same pipelines run in three places:

  • New assets, on Lennart's workstation. He runs Dagu in Docker Desktop to build each asset as he adds it.
  • Full rebuilds, on a dedicated laptop. When a release adds new features, the same pipeline rebuilds the whole library over several days.
  • Pipeline tests, in GitHub Actions. The pipeline has its own CI: a GitHub Actions job runs Dagu on test builds to check that assets still build after a change to a PowerShell script or a DAG.

The surface pipeline

Lennart's surface pipeline, redrawn from a screenshot of its graph in Dagu's web UI:

Lennart's surface pipeline, 22 steps in four stages. 1, check and prepare, five steps in a row: check the environment, check the source files, set up a workspace, rename the files, update the normal maps. 2, images, in two branches: resize the textures and then copy a thumbnail, while the preview media is resized; then optimize the PNG files and check the images. 3, files for each program, four in parallel: MaterialX, Blender, Godot and USD, where building the USDZ files waits for all four. 4, export to the website and to Nextcloud in parallel, then finish the run.

One material, as built

One material, as built. Paving Stones 036, a photogrammetry material from 2018. Dagu builds it into 8 ZIP files: 1K, 2K, 4K and 8K, each in JPG and PNG, from 9 MB for 1K JPG to 839 MB for 8K PNG. The 1K JPG ZIP holds the PBR maps, a preview image, and files for USD, Blender, MaterialX and Godot.

What made it work

  • No servers to run. Dagu is one binary that keeps its state in files, so the whole build system fits in one Docker image with nothing else to set up. The same pipelines run on Lennart's workstation, on a laptop for full rebuilds, and in GitHub Actions.
  • Existing tools as steps. The steps call PowerShell scripts, Blender, OpenUSD and other tools. Steps that don't depend on each other can run at the same time, like the four programs' files in the surface pipeline.
  • A failed check stops the build. In Dagu, the steps that depend on a failed step don't run. Both exports depend on the test steps, so a file that fails its test isn't exported.
  • The pipeline is tested before it runs. Dagu needs no server, so the pipeline's own CI runs it in GitHub Actions and checks that assets still build after a change to a script or a DAG.

Numbers and pipeline from Lennart Demes and ambientCG.com.

Dagu is one binary with no database. It runs next to your scripts, on whatever machine you have.