commit b3835c64eacc6e663f948295cb3fa38c6ccaf97d Author: Adam Dodman Date: Tue Feb 6 01:36:23 2018 +0000 Initial Commit diff --git a/AlpineBaseNotes.md b/AlpineBaseNotes.md new file mode 100644 index 0000000..733d2cc --- /dev/null +++ b/AlpineBaseNotes.md @@ -0,0 +1,66 @@ +# To create an alpine base image: + +Spin up a new VM: + - 512MB RAW Disk image (hence called alpine.img) + - Virtio Network bridge + - ISO of Alpine Virtual ed. attached + +Inside the VM: + - Add the following to /etc/network/interfaces: + + + auto lo + iface lo inet loopback + + auto eth0 + iface eth0 inet dhcp + hostname alpine + + - `/etc/init.d/networking restart` + - Run `setup-alpine`: + - gb + - gb + - alpine + - eth0 + - dhcp + - no + - [Enter twice] + - UTC + - none + - 1 + - openssh + - busybox + - sda + - sys + - y + + + - `passwd -d root` + - `poweroff` + +Make sure the VM is stopped. + +Run `virt-sysprep -a alpine.img` + +Run `xz -k -verbose -T4 --best --block-size=16777216 alpine.img` + +Create the index file as below. <> Shows commands to generate the required data. Replace version as needed. + + ``` + [alpine-37] + name=Alpine 3.7 + osinfo=alpine + arch=x86_64 + file=alpine.img.xz + checksum= + format=raw + size= + compressed_size= + expand=/dev/sda3 + ``` + +Sign the index file: + `gpg --clearsign --armor index` + + +Upload the generated `index.asc` and `alpine.img.xz` files to a web server. diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..68d1e67 --- /dev/null +++ b/Readme.md @@ -0,0 +1,8 @@ +# Alpine Drone Agent builder + +Create a VM for setting a drone build agent. + +Put alpinelinux.\* into /etc/xdg/virt-builder/repos.d/ + +Put your credentials into dronecfg, then +Run with `virt-builder --size 10G --format qcow2 --commands-from-file builder-commands` diff --git a/alpinelinux.conf b/alpinelinux.conf new file mode 100644 index 0000000..a92eaf5 --- /dev/null +++ b/alpinelinux.conf @@ -0,0 +1,5 @@ +# Put this file in /etc/xdg/virt-builder/repos.d to use the Alpine base images + +[Alpine] +uri=https://adam-ant.co.uk/builder/index.asc +gpgkey=file:///etc/xdg/virt-builder/repos.d/alpinelinux.gp diff --git a/alpinelinux.gpg b/alpinelinux.gpg new file mode 100644 index 0000000..56441d3 --- /dev/null +++ b/alpinelinux.gpg @@ -0,0 +1,53 @@ +# Put this file in /etc/xdg/virt-builder/repos.d to use the Alpine base images + +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQINBFeFdVUBEAC6uEuw0aWkcBducFNV2US3baRMmvspWlz4Lt1RJg5HNNA1R++V +XSwvSG8UFshtU50PVf8qGd7pN4h4Ei+Sr+MYoriG9zK9g2/ba3Q7R7EU3SgjiaWT +lZHaBdjjPvNydkR/7gFTSI4NAezycEkoE/oR2igDHnnM35XoBm1O2UwYmVjapLgN +6tP4YvPc4qTJNgDnkDXj4DE1Rr0Ybg/k5Fz8o+zlK8MB4W9ejK5XfyP1dIE7/tAp +Fjvwn5RY/BEvIz+jNP1HVTOtTIODlPxsJDGG1PwQc/xCT41IRqcVxDLhi0EFp3OJ +uucJAzPiKsB8zQhvt/FiFILBxMTWLCpoudI/B4gbFtMWlcsYksFWMiCB+pl33vij +xNOsi+ZHY6dR8rPcH6ChjKxeO4EUlUYAQXof3Wx5zJRUwYwN5IkYMnF4c1BXwifz +krvs9z4BVPd1TPYszY50CZPovU+NblJqUfvNVOZpalsJS+HYoOEsVuDK3r5uwupP +cMCOZf4RnyF3Sqfo1w50G0D0FvVmpgfoh4rD6d0YQ2Qn2jBoXlKP0SRUHkkEz28P +XtvN/JZb7YCEjzSG8Kh7/E4E3Z80ZRpxLrHjYJRtexdfsjmJ9G3ypNy4/dvJWsH9 +eGTXEUHZxPN6ZrPLGjsiNOkEKaaMXtsBCLiF3bAz0yA4lTKJfbZqOcpsCwARAQAB +tCFBZGFtIERvZG1hbiA8YWRhbS5kb2RtYW5AZ214LmNvbT6JAj0EEwEIACcFAleF +dVUCGwMFCRLMAwAFCwkIBwIGFQgJCgsCBBYCAwECHgECF4AACgkQeCaxCIlbhqpv +yA//bWHSr1PhoDc+ht1XsZZ/7Ycf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BLIC KEY BLOCK----- diff --git a/builder_commands b/builder_commands new file mode 100644 index 0000000..1e8a5a8 --- /dev/null +++ b/builder_commands @@ -0,0 +1,37 @@ +# Enable the community repo +edit /etc/apk/repositories:'s/^#\(.*community\)/\1/g' + +# Setup the new MOTD +run motd.sh + +# Disallow root login +root-password disabled +edit /etc/ssh/sshd_config:'/^PermitRootLogin yes/d' + +# Set up the docker user +update +install docker +install sudo +install shadow +run-command adduser -D -G docker docker +run-command { echo changeme; echo changeme; } | passwd docker +run-command echo changeme | chage -d 0 docker +run-command echo 'docker ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers.d/docker-nopasswd +chmod 0640:/etc/sudoers.d/* + +# Install docker +install docker +run-command rc-update add docker boot +run-command service docker start + +# Install docker-compose +install python +install py-pip +run-command pip install docker-compose +uninstall py-pip + +# Set up pruning docker every 15 minutes. Useful for build agents +run-command rc-update add crond +run-command echo '*/15 * * * * docker system prune -a -f --filter until=10m' | crontab -u docker - + +# Install the drone-agent starters diff --git a/drone-agent.start b/drone-agent.start new file mode 100644 index 0000000..08b9ae3 --- /dev/null +++ b/drone-agent.start @@ -0,0 +1,2 @@ +#! /bin/sh +docker-compose -f /etc/drone-compose.yml up --force-recreate -d diff --git a/drone-compose.yml b/drone-compose.yml new file mode 100644 index 0000000..4a4a4a4 --- /dev/null +++ b/drone-compose.yml @@ -0,0 +1,14 @@ +version: '3.1' + +# Run this on a dedicated box only! +# It WILL make a mess of the docker daemon + +services: + agent: + image: drone/agent:0.8.4 + container_name: drone-agent + command: agent + restart: always + volumes: + - /var/run/docker.sock:/var/run/docker.sock + env_file: /etc/dronecfg diff --git a/motd.sh b/motd.sh new file mode 100644 index 0000000..f32314e --- /dev/null +++ b/motd.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +source /etc/os-release + +cat << EOF > /etc/motd + +$PRETTY_NAME ($VERSION_ID) Docker Host + +Built as a CI runner for Docker-based CI platforms + such as Drone-CI https://github.com/drone/drone + +See the Alpine Wiki for how-to guides and +general information about administrating +Alpine systems and development. +See + +EOF +