magic containerized builds
redbuild enables software to be built in pre-defined environments using the power of containerization. with podman installed, any supported project can be built with a single command. projects provide a build.docker and build.sh for defining the build environment and build steps.
redbuild: just add water!
# with pipx (recommended)
pipx install redbuild
# with vanilla pip
pip install redbuildlocal install:
poetry install
poetry run redbuild --helpcontainerized bootstrap (optional):
./bootstrap/redbuild.shcd example
redbuild build-
create a
build.dockerfile in the project root. this file should contain aFROMdirective for the base image to use for the build environment. the build environment should contain all the tools necessary to build the project. it's also very important that the last line of the dockerfile isCMD ["/bin/bash", "-l"]. this is necessary for redbuild to work.an example
build.docker:FROM debian:bookworm-slim # install dependencies RUN apt-get update && apt-get install -y \ bash \ curl wget xz-utils \ gcc make libc6-dev libcurl4 \ git libxml2 \ && rm -rf /var/lib/apt/lists/* && apt autoremove -y && apt clean # install dlang RUN curl -fsS https://dlang.org/install.sh | bash -s install ldc-1.30.0 \ && echo "source ~/dlang/ldc-1.30.0/activate" >> ~/.bashrc # set up main to run bash (necessary for redbuild) CMD ["/bin/bash", "-l"]
-
create a
build.shfile in the project root. this file should contain the steps necessary to build the project. the build script should be written to be run in the build environment.build.sh:#!/usr/bin/env bash set -e dub build --compiler ldc2 -B release
make it executable:
chmod +x build.sh
that's it! now you can build the project with redbuild build, copy it into the project root, and run it. you can also open an interactive shell in the build environment with redbuild shell.