Skip to content

Building with Docker

Guy Sheffer edited this page Oct 28, 2024 · 21 revisions

Docker building image is available at Docker Hub. Ensure you have set up the loop module if necessary (sudo modprobe loop).

Docker Run

To use it go the folder of your distro and run:

cd distro/src
docker run --rm -v `pwd`:/distro --device /dev/loop-control guysoft/custompios:devel build

On MacOS, add --privileged flag to the Linux Docker parameters.

On Win10, running Docker Desktop and WSL2, you might want to try this instead:

docker run --rm -v C:/path/to/your/distro/src:/distro --privileged guysoft/custompios:devel build --download

Note: you are mounting the src folder of your image to the docker container. Make sure that it contains the config file, the modules folder, the image folder etc.

Note that --downlaod makes sure sure you have the base image you want to build with. You can also do this manually by running something like:

cd src/image
wget -c --trust-server-names 'https://downloads.raspberrypi.org/raspios_lite_armhf_latest'
cd ..

Your image would be created as a zip file at distro/src/workspace If you are building a variant it will appear in distro/src/workspace-{variant-name}

Docker-Compose

You can also use this example docker-compose.yml in distro/src (src/docker/docker-compose.yml):

version: '3.6'

services:
  custompios:
    image: guysoft/custompios:devel
    container_name: mydistro_builder
    tty: true
    restart: always
    privileged: true
    volumes:
      - ./:/distro
    devices:
      - /dev/loop-control

Auto-update using containrrr/watchtower

It is recommended to build against the latest in the CustomPiOS repo, there is an automated build, so you can add a watchtower that will always keep the CustomPiOS docker image up do date, by using v2tec/watchtower:

version: '3.6'

services:
  custompios:
    image: guysoft/custompios:devel
    container_name: ${DISTRO_NAME}-build
    tty: true
    restart: always
    privileged: true
    volumes:
      - ./:/distro
    devices:
      - /dev/loop-control
    labels:
      - com.centurylinklabs.watchtower.enable=true

  watchtower:
    image: containrrr/watchtower
    container_name: custompios-watcher
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /root/.docker/config.json:/config.json
    command: --cleanup --label-enable --interval 30
    restart: always

Then:

echo "DISTRO_NAME" > .env