diff options
author | Vincent Batts <vbatts@hashbangbash.com> | 2014-01-30 13:13:54 -0600 |
---|---|---|
committer | Erik Hanson <erik@slackbuilds.org> | 2014-02-08 11:09:51 -0600 |
commit | f1e2b846410cb6fc34da5f3ce4b85dc035810eb3 (patch) | |
tree | 8ba3233a0e734b21498d7f967e4e82afdf557c6a | |
parent | 3059f8abc4dcd52c9b2c3f702505b51b83517ab5 (diff) |
system/docker: Added (manager for applications in linux containers)
Signed-off-by: Robby Workman <rworkman@slackbuilds.org>
-rw-r--r-- | system/docker/README | 26 | ||||
-rw-r--r-- | system/docker/config/docker.default | 3 | ||||
-rw-r--r-- | system/docker/config/docker.logrotate | 8 | ||||
-rw-r--r-- | system/docker/config/rc.docker | 80 | ||||
-rw-r--r-- | system/docker/docker-btrfs.patch | 32 | ||||
-rw-r--r-- | system/docker/docker.SlackBuild | 92 | ||||
-rw-r--r-- | system/docker/docker.info | 10 | ||||
-rw-r--r-- | system/docker/doinst.sh | 28 | ||||
-rw-r--r-- | system/docker/slack-desc | 19 |
9 files changed, 298 insertions, 0 deletions
diff --git a/system/docker/README b/system/docker/README new file mode 100644 index 0000000000000..34a2d621ba81a --- /dev/null +++ b/system/docker/README @@ -0,0 +1,26 @@ +Docker is an open-source project to easily create lightweight, portable, +self-sufficient containers from any application. The same container that +a developer builds and tests on a laptop can run at scale, in production, +on VMs, bare metal, OpenStack clusters, public clouds and more. + +To use docker as a limited user, add your user to the 'docker' group: + + # groupadd -r -g 278 docker + # usermod -a -G docker <your_username> + +This will require logging out and back in. + +To have the docker daemon start and stop with your host, +add to /etc/rc.d/rc.local: + + if [ -x /etc/rc.d/rc.docker ]; then + /etc/rc.d/rc.docker start + fi + +and to /etc/rc.d/rc.local_shutdown (creating it if needed): + + if [ -x /etc/rc.d/rc.docker ]; then + /etc/rc.d/rc.docker stop + fi + +NOTE: google-go-lang is only needed at compile time - not needed for runtime. diff --git a/system/docker/config/docker.default b/system/docker/config/docker.default new file mode 100644 index 0000000000000..ae2989490d569 --- /dev/null +++ b/system/docker/config/docker.default @@ -0,0 +1,3 @@ +## Set defaults used by the docker daemon +## These are flags passed after `docker -d` +#DOCKER_OPTS= diff --git a/system/docker/config/docker.logrotate b/system/docker/config/docker.logrotate new file mode 100644 index 0000000000000..41f96a65d4810 --- /dev/null +++ b/system/docker/config/docker.logrotate @@ -0,0 +1,8 @@ +/var/log/docker.log { + rotate 5 + notifempty + missingok + size=5M + compress + delaycompress +} diff --git a/system/docker/config/rc.docker b/system/docker/config/rc.docker new file mode 100644 index 0000000000000..bf6e183e4cc81 --- /dev/null +++ b/system/docker/config/rc.docker @@ -0,0 +1,80 @@ +#!/bin/sh + +# Short-Description: Create lightweight, portable, self-sufficient containers. +# Description: +# Docker is an open-source project to easily create lightweight, portable, +# self-sufficient containers from any application. The same container that a +# developer builds and tests on a laptop can run at scale, in production, on +# VMs, bare metal, OpenStack clusters, public clouds and more. + + +PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin + +BASE=docker + +DOCKER=/usr/bin/$BASE +DOCKER_PIDFILE=/var/run/$BASE.pid +DOCKER_LOG=/var/log/docker.log +DOCKER_OPTS= + +if [ -f /etc/default/$BASE ]; then + . /etc/default/$BASE +fi + +# Check docker is present +if [ ! -x $DOCKER ]; then + echo "$DOCKER not present or not executable" + exit 1 +fi + +docker_start() { + echo "starting $BASE ..." + if [ -x ${DOCKER} ]; then + # If there is an old PID file (no docker running), clean it up: + if [ -r ${DOCKER_PIDFILE} ]; then + if ! ps axc | grep docker 1> /dev/null 2> /dev/null ; then + echo "Cleaning up old ${DOCKER_PIDFILE}." + rm -f ${DOCKER_PIDFILE} + fi + fi + nohup ${DOCKER} -d -p ${DOCKER_PIDFILE} ${DOCKER_OPTS} >> ${DOCKER_LOG} 2>&1 & + fi +} + +# Stop docker: +docker_stop() { + echo "stopping $BASE ..." + # If there is no PID file, ignore this request... + if [ -r ${DOCKER_PIDFILE} ]; then + kill $(cat ${DOCKER_PIDFILE}) + fi +} + +# Restart docker: +docker_restart() { + docker_stop + docker_start +} + +case "$1" in +'start') + docker_start + ;; +'stop') + docker_stop + ;; +'restart') + docker_restart + ;; +'status') + if [ -f ${DOCKER_PIDFILE} ] && ps -o cmd $(cat ${DOCKER_PIDFILE}) | grep -q $BASE ; then + echo "status of $BASE: running" + else + echo "status of $BASE: stopped" + fi + ;; +*) + echo "usage $0 start|stop|restart|status" +esac + +exit 0 diff --git a/system/docker/docker-btrfs.patch b/system/docker/docker-btrfs.patch new file mode 100644 index 0000000000000..ef6c540881034 --- /dev/null +++ b/system/docker/docker-btrfs.patch @@ -0,0 +1,32 @@ +commit 6922f1be08111d889b0585b763b08f92d7a55e05 +Author: Tianon Gravi <admwiggin@gmail.com> +Date: Sat Feb 1 21:40:51 2014 -0700 + + Remove reference to <linux/btrfs.h>, and instead use <btrfs/ioctl.h> like we're supposed to (from btrfs-progs) + + This fixes compilation issues when btrfs.h isn't available (because we just need the relevant structs, which for userspace programs are supposed to come from btrfs-progs instead of the kernel headers). + + Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon) + +diff --git a/graphdriver/btrfs/btrfs.go b/graphdriver/btrfs/btrfs.go +index a50f11f..3d27909 100644 +--- a/graphdriver/btrfs/btrfs.go ++++ b/graphdriver/btrfs/btrfs.go +@@ -4,15 +4,11 @@ package btrfs + + /* + #include <stdlib.h> +-#include <sys/ioctl.h> +-#include <linux/fs.h> +-#include <errno.h> +-#include <sys/types.h> + #include <dirent.h> +-#include <linux/btrfs.h> +- ++#include <btrfs/ioctl.h> + */ + import "C" ++ + import ( + "fmt" + "github.com/dotcloud/docker/graphdriver" diff --git a/system/docker/docker.SlackBuild b/system/docker/docker.SlackBuild new file mode 100644 index 0000000000000..a442fef79fe85 --- /dev/null +++ b/system/docker/docker.SlackBuild @@ -0,0 +1,92 @@ +#!/bin/sh + +# Slackware build script for docker + +# Written by Vincent Batts <vbatts@hashbangbash.com> + +PRGNAM=docker +VERSION=${VERSION:-0.8.0} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} + +GITHASH=${GITHASH:-cc3a8c8} + +# Automatically determine the architecture we're building on: +if [ -z "$ARCH" ]; then + case "$( uname -m )" in + i?86) ARCH=i486 ;; + arm*) ARCH=arm ;; + # Unless $ARCH is already set, use uname -m for all other archs: + *) ARCH=$( uname -m ) ;; + esac +fi + +CWD=$(pwd) +TMP=${TMP:-/tmp/SBo} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +if [ "$ARCH" = "i486" ]; then + SLKCFLAGS="-O2 -march=i486 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "i686" ]; then + SLKCFLAGS="-O2 -march=i686 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "x86_64" ]; then + SLKCFLAGS="-O2 -fPIC" + LIBDIRSUFFIX="64" +else + SLKCFLAGS="-O2" + LIBDIRSUFFIX="" +fi + +set -e + +rm -rf $PKG +mkdir -p $TMP $PKG $OUTPUT +cd $TMP +rm -rf $PRGNAM-$VERSION +tar xvf $CWD/v${VERSION}.tar.gz || tar xvz $PRGNAM-$VERSION.tar.gz +cd $PRGNAM-$VERSION +chown -R root:root . +find . \ + \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ + -exec chmod 755 {} \; -o \ + \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ + -exec chmod 644 {} \; + +unset GOPATH + +mkdir -p ${PKG}/usr/share/gocode/src/github.com/dotcloud/docker +cp -a . ${PKG}/usr/share/gocode/src/github.com/dotcloud/docker/ + +# back out this commit, which causes btrfs headers to not be found on slackware +# since btrfs-progs removes the <btrfs/ioctl.h> header. +# https://github.com/dotcloud/docker/commit/6922f1be08111d889b0585b763b08f92d7a55e05 +patch -p1 -R < $CWD/docker-btrfs.patch + +GOPATH=${PKG}/usr/share/gocode:$(pwd)/vendor \ +DOCKER_GITCOMMIT="$GITHASH" \ + ./hack/make.sh dynbinary + +# do not strip these binaries. they have a SHA1 baked into them. +mkdir -p ${PKG}/usr/libexec/docker ${PKG}/usr/bin +mv bundles/${VERSION}/dynbinary/dockerinit-${VERSION} ${PKG}/usr/libexec/docker/dockerinit +mv bundles/${VERSION}/dynbinary/docker-${VERSION} ${PKG}/usr/bin/docker + +install -D --mode 0644 $CWD/config/docker.default $PKG/etc/default/docker.new +install -D --mode 0644 $CWD/config/docker.logrotate $PKG/etc/logrotate.d/docker.new +install -D --mode 0755 $CWD/config/rc.docker $PKG/etc/rc.d/rc.docker.new + +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION +cp -a \ + AUTHORS CONTRIBUTING.md CHANGELOG.md FIXME LICENSE README.md NOTICE VERSION \ + $PKG/usr/doc/$PRGNAM-$VERSION +cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc +cat $CWD/doinst.sh > $PKG/install/doinst.sh + +cd $PKG +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz} diff --git a/system/docker/docker.info b/system/docker/docker.info new file mode 100644 index 0000000000000..db6e84c2eb773 --- /dev/null +++ b/system/docker/docker.info @@ -0,0 +1,10 @@ +PRGNAM="docker" +VERSION="0.8.0" +HOMEPAGE="https://docker.io/" +DOWNLOAD="https://github.com/dotcloud/docker/archive/v0.8.0.tar.gz" +MD5SUM="737aec190c2ad81b00192f858f9ed31b" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +REQUIRES="google-go-lang" +MAINTAINER="Vincent Batts" +EMAIL="vbatts@hashbangbash.com" diff --git a/system/docker/doinst.sh b/system/docker/doinst.sh new file mode 100644 index 0000000000000..56e6b591a257e --- /dev/null +++ b/system/docker/doinst.sh @@ -0,0 +1,28 @@ +config() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + # If there's no config file by that name, mv it over: + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then + # toss the redundant copy + rm $NEW + fi + # Otherwise, we leave the .new copy for the admin to consider... +} + +preserve_perms() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + if [ -e $OLD ]; then + cp -a $OLD ${NEW}.incoming + cat $NEW > ${NEW}.incoming + mv ${NEW}.incoming $NEW + fi + config $NEW +} + +preserve_perms etc/rc.d/rc.docker.new +config etc/default/docker.new +config etc/logrotate.d/docker.new + diff --git a/system/docker/slack-desc b/system/docker/slack-desc new file mode 100644 index 0000000000000..d8d5ae65e6f53 --- /dev/null +++ b/system/docker/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. +# Line up the first '|' above the ':' following the base package name, and +# the '|' on the right side marks the last column you can put a character in. +# You must make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +docker: docker (manager for applications in linux containers) +docker: +docker: Docker is an open-source project to easily create lightweight, +docker: portable, self-sufficient containers from any application. The same +docker: container that a developer builds and tests on a laptop can run at +docker: scale, in production, on VMs, bare metal, OpenStack clusters, public +docker: clouds and more. +docker: +docker: Homepage: https://docker.io/ +docker: +docker: |