# http://github.com/elijahr/build-farm

# By default, the client containers will assume that a compiler image is 
# running in the same docker network. The compiler address is configured 
# via the environment variable: 

#DISTCC_HOSTS

# whose default value is:
#	172.17.0.1:<compiler-port>, where
#       	172.17.0.1 is the default Docker network IP and 
#	<compiler-port> corresponds to the table above. (3603-3611)
       
# These defaults should work for most Docker installations.  


# The client containers require the multiarch/qemu-user-static package for emulation
# which can be installed via:

sudo apt-get update -q -y
sudo apt-get -qq install -y qemu qemu-user-static


# On x86_64 machine register QEMU:

docker run -it --rm --privileged multiarch/qemu-user-static --reset --credential yes --persistent yes

# Image:      elijahru/build-farm-client:debian-buster 
# Slim image: elijahru/build-farm-client:debian-buster-slim


# Platform 		DISTCC_HOSTS
# linux/amd64 		172.17.0.1:3604
# linux/386 		172.17.0.1:3603
# linux/arm/v5 		172.17.0.1:3605
# linux/arm/v7 		172.17.0.1:3607
# linux/arm64/v8 	172.17.0.1:3608
# linux/ppc64le 	172.17.0.1:3610
# linux/s390x 		172.17.0.1:3609
# linux/mips64le 	172.17.0.1:3611


HOST_DEST="/space/code-repositories/docker/build-farm_host"
mkdir -p ${CLIENT_HOST}

cat > ${HOST_DEST}/docker-compose.yml <<EOF
version: '3'
services:
  build-host:
    image: elijahru/build-farm:debian-buster
    ports:
      - 3704:3704
EOF

## Where the Makefile lives.
#CLIENT_DEST="/space/code-repositories/docker/build-farm_client"
#CLIENT_DEST="/space/code-repositories/docker/buildroot"
#mkdir -p ${CLIENT_DEST}

#cat > ${CLIENT_DEST}/buildroot <<EOF
#version: '3'
#services:
#  client:
#    environment:
#      - DISTCC_HOSTS="build-host1:3704 build-host2:3704 build-host3:3704"
#    image: elijahru/build-farm-client:debian-buster
#    volumes:
#      - .:/buildroot
#    command: ./make rockpro64_defconfig && make
#EOF
