diff options
| author | Mhd Sulhan <ms@kilabit.info> | 2015-09-05 22:16:52 +0700 |
|---|---|---|
| committer | Mhd Sulhan <ms@kilabit.info> | 2015-09-05 22:16:52 +0700 |
| commit | 8dba030949eb263d0e5344309874f747f6673750 (patch) | |
| tree | 119a2f21245dcb286321eb942b346791e8331cb8 | |
| parent | 9bdaec2b19e6e56df3dac2bbc9da6ca9683190d9 (diff) | |
| download | arch-docker-8dba030949eb263d0e5344309874f747f6673750.tar.xz | |
Add script to create image for Buildbot master and slave.
| l--------- | arch-buildbot/Dockerfile | 1 | ||||
| -rw-r--r-- | arch-buildbot/Dockerfile.local | 14 | ||||
| -rw-r--r-- | arch-buildbot/Dockerfile.online | 12 | ||||
| -rwxr-xr-x | arch-buildbot/bootstrap.sh | 50 | ||||
| -rwxr-xr-x | arch-buildbot/build.sh | 66 | ||||
| -rwxr-xr-x | arch-buildbot/init.sh | 11 |
6 files changed, 154 insertions, 0 deletions
diff --git a/arch-buildbot/Dockerfile b/arch-buildbot/Dockerfile new file mode 120000 index 0000000..bd8469a --- /dev/null +++ b/arch-buildbot/Dockerfile @@ -0,0 +1 @@ +Dockerfile.online
\ No newline at end of file diff --git a/arch-buildbot/Dockerfile.local b/arch-buildbot/Dockerfile.local new file mode 100644 index 0000000..a13bbe3 --- /dev/null +++ b/arch-buildbot/Dockerfile.local @@ -0,0 +1,14 @@ +FROM sulhan/arch-nodejs:latest +MAINTAINER Sulhan <ms@kilabit.info> + +VOLUME /srv/www +EXPOSE 8010 + +COPY init.sh / +COPY bootstrap.sh / +COPY *.db /var/lib/pacman/sync/ +COPY *.xz /var/cache/pacman/pkg/ + +RUN exec /bootstrap.sh + +CMD ["/init.sh"] diff --git a/arch-buildbot/Dockerfile.online b/arch-buildbot/Dockerfile.online new file mode 100644 index 0000000..a8c82ea --- /dev/null +++ b/arch-buildbot/Dockerfile.online @@ -0,0 +1,12 @@ +FROM sulhan/arch-nodejs:latest +MAINTAINER Sulhan <ms@kilabit.info> + +VOLUME /srv/www +EXPOSE 8010 + +COPY init.sh / +COPY bootstrap.sh / + +RUN exec /bootstrap.sh + +CMD ["/init.sh"] diff --git a/arch-buildbot/bootstrap.sh b/arch-buildbot/bootstrap.sh new file mode 100755 index 0000000..1db4ceb --- /dev/null +++ b/arch-buildbot/bootstrap.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +PACKAGES="buildbot buildbot-slave" + +strip_bin() { + find /usr/bin -type f \( -perm -0100 \) -print | + xargs file | + sed -n '/executable .*not stripped/s/: TAB .*//p' | + xargs -rt strip --strip-unneeded +} + +strip_lib() { + find /usr/lib -type f \( -perm -0100 \) -print | + xargs file | + sed -n '/executable .*not stripped/s/: TAB .*//p' | + xargs -rt strip --strip-unneeded +} + +clean_common() { + echo "==> cleaning ..." + strip_bin + strip_lib + rm -rf /usr/share/doc/* + rm -rf /usr/share/licenses/* + rm -rf /usr/share/locale/* + rm -rf /usr/share/man/* + rm -rf /usr/share/info/* + rm -rf /var/cache/pacman/pkg/* + rm -rf /var/log/* + rm -f /bootstrap.sh +} + +do_install() { + pacman -S --noconfirm $PACKAGES + return $? +} + +do_fix_python() { + easy_install-2.7 sqlalchemy==0.7.10 sqlalchemy-migrate==0.7.2 + return $? +} + +do_install +while [ $? -ne 0 ]; do do_install; done + +do_fix_python +while [ $? -ne 0 ]; do do_fix_python; done + +## cleaning ... +clean_common diff --git a/arch-buildbot/build.sh b/arch-buildbot/build.sh new file mode 100755 index 0000000..fea4566 --- /dev/null +++ b/arch-buildbot/build.sh @@ -0,0 +1,66 @@ +#!/bin/sh + +## +## Maintainer: Sulhan <ms@kilabit.info> +## +## Script to build buildbot (master and slave) image using `sulhan/arch-base` +## as base system. +## +## Usage +## ./build.sh [local|clean] +## +## If no parameter is given, it will sync and install package from container. +## +## local +## update host db and packages first and copy the db and packages to +## container. +## + +PACKAGES="buildbot buildbot-slave" +IMAGE_NAME="sulhan/arch-buildbot" + +clean() { + rm -f *.db + rm -f *.xz + rm -f Dockerfile + ln -s Dockerfile.online Dockerfile + exit $1 +} + +docker_build() { + docker build --force-rm -t $IMAGE_NAME . + s=$? + clean $s +} + +if [[ $# = 0 ]]; then + echo "==> Building docker image online ..." + docker_build +fi + +if [[ -z $1 || $1 != local ]]; then + echo "Usage: ./build.sh [online]" + exit 1 +fi + +if [[ $1 = "clean" ]]; then + clean +fi + +echo "==> Building docker image using local db and packages ..." + +## always make sure local db and packages up to date. +## npm require python, make, gcc to rebuild packages. +sudo pacman -Syw --noconfirm --needed $PACKAGES +sudo pacman -Sc --noconfirm + +cp /var/lib/pacman/sync/*.db ./ + +## buildbot +cp /var/cache/pacman/pkg/python2-*.* \ + /var/cache/pacman/pkg/buildbot* ./ + ./ + +rm -f Dockerfile +ln -s Dockerfile.local Dockerfile +docker_build diff --git a/arch-buildbot/init.sh b/arch-buildbot/init.sh new file mode 100755 index 0000000..2d1ecc0 --- /dev/null +++ b/arch-buildbot/init.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +BUILDBOT_D=/srv/www + +if [ -d ${BUILDBOT_D}/master ]; then + buildbot start ${BUILDBOT_D}/master +fi + +if [ -d ${BUILDBOT_D}/slave ]; then + buildslave start ${BUILDBOT_D}/slave +fi |
