bottlerocket-os / twoliter

A build tool for customizing Bottlerocket
Other
23 stars 22 forks source link

Investigate if a variant build can be built inside a container #333

Open jmt-lab opened 1 month ago

jmt-lab commented 1 month ago

A customer attempted to build bottlerocket variants inside of a docker container with the docker daemon socket shared between the host and the container. The build failed when buildsys orchestrated docker build to mount the sources into the build context because of the directory going from container volume -> host -> build-context. (https://github.com/bottlerocket-os/bottlerocket/issues/4100)

We should investigate whether it would be possible for this flow to work. Roughly we could allow the user to specify a host path that is shared via a mounted volume in both the build container and then in the build context.

jmt-lab commented 1 month ago

Current workaround used for this:

#!/usr/bin/env bash
git clone https://github.com/bottlerocket-os/bottlerocket.git
cd bottlerocket
BOTTLEROCKET_PATH="$(pwd)"

cat <<EOF >> build.sh
#!/usr/bin/env bash
apt update
apt install -y --no-install-recommends docker.io docker-buildx
docker image ls
apt install -y build-essential openssl libssl-dev pkg-config liblz4-tool
apt install -y rustup git curl
rustup install stable || true
cargo install cargo-make
cd "${BOTTLEROCKET_PATH}"
cargo make
EOF

docker run --rm -it -v "/tmp:/tmp" -v "/var/run/docker.sock:/var/run/docker.sock" -v "${BOTTLEROCKET_PATH}:${BOTTLEROCKET_PATH}" ubuntu sh -c "cd ${BOTTLEROCKET_PATH} && chmod +x ./build.sh && ./build.sh"

We should see if we can fix pipesys and temp sharing for sbkeys to make this better