guix icon indicating copy to clipboard operation
guix copied to clipboard

Solve issues in docker multi architecture builds (linux/arm/v7, linux/arm64/v8, linux/ppc64le)

Open viferga opened this issue 1 year ago • 3 comments

linux/arm/v7

It seems this issue depends on the kernel image, we should investigate it further:

          # guix error: cloning builder process: Invalid argument (https://lists.gnu.org/archive/html/help-guix/2017-12/msg00023.html)
          # { docker: linux/arm/v7, guix: armhf-linux },

Reference: https://lists.gnu.org/archive/html/help-guix/2017-12/msg00023.html

linux/arm64/v8, linux/ppc64le

For OOM, we should find a way to tweak QEMU options and truly investigate if the OOM is reached due to QEMU limits or the VM from GitHub itself. Here's the reference:

          # ERROR: failed to solve: ResourceExhausted: process "/bin/sh -c sh -c '/entry-point.sh guix pull ..." did not complete successfully: cannot allocate memory
          # { docker: linux/arm64/v8, guix: aarch64-linux },
          # { docker: linux/ppc64le, guix: powerpc64le-linux }

Reference: https://github.com/docker/setup-qemu-action https://hub.docker.com/r/tonistiigi/binfmt https://github.com/tonistiigi/binfmt

viferga avatar Oct 15 '24 21:10 viferga

I’ve attempted several strategies to resolve the multi-architecture build issues, including:

1. Limiting Guix to a single job (Guix=jobs=1)

  • In the Dockerfile, I set the GUIX_JOBS environment variable to limit the number of jobs to 1:
    ENV GUIX_JOBS=1
    

2. Increasing the swap space to 16GB

  • I added a step in the Docker workflow to increase the swap space before running the build:
    sudo fallocate -l 16G /swapfile
    sudo chmod 600 /swapfile
    sudo mkswap /swapfile
    sudo swapon /swapfile
    
  • Verified the swap space with:
    swapon --show
    free -h
    

3. Setting memory limits to 4GB for Docker containers

  • In the Docker run command, I limited the memory to 4GB:
    docker run --memory=4g ...
    

4. Splitting commands in the Dockerfile

  • To optimize the build process, I split the RUN commands in the Dockerfile to isolate steps and reduce the chance of failures:
    RUN guix pull
    RUN guix package --fallback -i nss-certs
    

5. Commenting out other platforms

  • To focus exclusively on arm64/v8, I commented out the other platforms in the Docker build command:
    docker buildx build --platform linux/arm64/v8 --push ...
    

6. Trying different base images

  • I tested different base images such as debian:bookworm and debian:bookworm-slim by modifying the FROM line in the Dockerfile:
    FROM debian:bookworm
    
    or
    FROM debian:bookworm-slim
    

7. Installing Guix via the official Guix script

  • I also attempted to install Guix using the official installation script:
    wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
    sudo bash guix-install.sh
    

Despite trying all these solutions, the problem is still not resolved. Any further advice or suggestions would be really helpful.

mryashlk avatar Oct 16 '24 18:10 mryashlk

@Bcoderx6 thank you so much for the investigation.

viferga avatar Oct 16 '24 21:10 viferga

I have added more substitutes, we should try to uncomment it and run it again:

viferga avatar Sep 26 '25 15:09 viferga