From owner-svn-ports-head@freebsd.org Mon Jul 6 15:37:37 2015 Return-Path: Delivered-To: svn-ports-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F2602A1D6; Mon, 6 Jul 2015 15:37:36 +0000 (UTC) (envelope-from kmoore@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E147D156D; Mon, 6 Jul 2015 15:37:36 +0000 (UTC) (envelope-from kmoore@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t66FbapD022981; Mon, 6 Jul 2015 15:37:36 GMT (envelope-from kmoore@FreeBSD.org) Received: (from kmoore@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t66FbYeo022971; Mon, 6 Jul 2015 15:37:34 GMT (envelope-from kmoore@FreeBSD.org) Message-Id: <201507061537.t66FbYeo022971@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kmoore set sender to kmoore@FreeBSD.org using -f From: Kris Moore Date: Mon, 6 Jul 2015 15:37:34 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r391421 - in head/sysutils: . docker docker/files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jul 2015 15:37:37 -0000 Author: kmoore Date: Mon Jul 6 15:37:33 2015 New Revision: 391421 URL: https://svnweb.freebsd.org/changeset/ports/391421 Log: FreeBSD port of Docker WWW: https://github.com/kvasdopil/docker NOTE: This is a very early port of docker! Please refer to the pkg-message and https://github.com/kvasdopil/docker/blob/freebsd-compat/FREEBSD-PORTING.md for details on usage and functionality. Added: head/sysutils/docker/ head/sysutils/docker/Makefile (contents, props changed) head/sysutils/docker/distinfo (contents, props changed) head/sysutils/docker/files/ head/sysutils/docker/files/docker.in (contents, props changed) head/sysutils/docker/pkg-descr (contents, props changed) head/sysutils/docker/pkg-message (contents, props changed) Modified: head/sysutils/Makefile Modified: head/sysutils/Makefile ============================================================================== --- head/sysutils/Makefile Mon Jul 6 15:16:25 2015 (r391420) +++ head/sysutils/Makefile Mon Jul 6 15:37:33 2015 (r391421) @@ -201,6 +201,7 @@ SUBDIR += djmount SUBDIR += dmg2img SUBDIR += dmidecode + SUBDIR += docker SUBDIR += doinkd SUBDIR += dolly SUBDIR += downtime Added: head/sysutils/docker/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/docker/Makefile Mon Jul 6 15:37:33 2015 (r391421) @@ -0,0 +1,36 @@ +# Created by: kmoore@FreeBSD.org +# $FreeBSD$ + +PORTNAME= docker +PORTVERSION= 06252015 +CATEGORIES= sysutils + +MAINTAINER= kmoore@FreeBSD.org +COMMENT= Docker containment system + +LICENSE= APACHE20 +LICENSE_FILE= ${WRKSRC}/LICENSE + +BUILD_DEPENDS= ${LOCALBASE}/bin/go:${PORTSDIR}/lang/go \ + ${LOCALBASE}/bin/bash:${PORTSDIR}/shells/bash \ + ${LOCALBASE}/bin/git:${PORTSDIR}/devel/git \ + sqlite3:${PORTSDIR}/databases/sqlite3 +RUN_DEPENDS= ${LOCALBASE}/bin/go:${PORTSDIR}/lang/go \ + ${LOCALBASE}/bin/bash:${PORTSDIR}/shells/bash \ + sqlite3:${PORTSDIR}/databases/sqlite3 + +USE_GITHUB= yes +GH_ACCOUNT= kvasdopil +GH_TAGNAME= 582db78 + +PLIST_FILES= bin/docker +USE_RC_SUBR= docker + +do-build: + @cd ${WRKSRC} && export AUTO_GOPATH=1 && export DOCKER_GITCOMMIT=${GH_TAGNAME} && ./hack/make.sh binary + +do-install: + @${MKDIR} ${STAGEDIR}${PREFIX}/bin + ${INSTALL} ${WRKSRC}/bundles/latest/binary/docker ${STAGEDIR}${PREFIX}/bin/ + +.include Added: head/sysutils/docker/distinfo ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/docker/distinfo Mon Jul 6 15:37:33 2015 (r391421) @@ -0,0 +1,2 @@ +SHA256 (kvasdopil-docker-06252015-582db78_GH0.tar.gz) = a750d344af4af3d30b1a3373f382ab597a2a7aa4a0bb5c22d650d0c5cc9ac506 +SIZE (kvasdopil-docker-06252015-582db78_GH0.tar.gz) = 7292884 Added: head/sysutils/docker/files/docker.in ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/docker/files/docker.in Mon Jul 6 15:37:33 2015 (r391421) @@ -0,0 +1,82 @@ +#!/bin/sh + +# PROVIDE: docker +# REQUIRE: DAEMON +# KEYWORD: nojail shutdown + +. /etc/rc.subr + +name="docker" +rcvar="docker_enable" + +stop_cmd="docker_stop" +start_cmd="docker_start" +command="%%PREFIX%%/bin/docker" + +load_rc_config $name + +: ${docker_enable=NO} +: ${docker_dir=/usr/docker} +: ${docker_nat_pf=YES} +: ${docker_nat_iface=NONE} + +docker_start() +{ + if [ ! -d "${docker_dir}" ] ; then + echo "Missing ${docker_dir}! Please create / mount a ZFS dataset at this location." + exit 1 + fi + + if [ -e "/var/run/docker.pid" ] ; then + pgrep -F /var/run/docker.pid 2>/dev/null >/dev/null + if [ $? -eq 0 ] ; then + echo "Docker already running? /var/run/docker.pid" + exit 1 + fi + fi + + echo "Starting docker..." + daemon -p /var/run/docker.pid ${command} -d -e jail -s zfs -g ${docker_dir} -D >/var/log/docker.log 2>/var/log/docker.log + + # Check for linux 64bit support and enable + kldstat | grep -q 'linux64' + if [ $? -ne 0 -a -e "/boot/kernel/linux64.ko" ] ; then + kldload linux64 + fi + + # Check for NAT support via PF + # This is an ugly experimental hack for now, eventually will go away + if [ "${docker_nat_pf}" != "YES" ] ; then return ; fi + + # Load PF if not already + kldstat | grep -q 'pf.ko' + if [ $? -ne 0 -a -e "/boot/kernel/pf.ko" ] ; then + kldload pf + fi + + # Check if PF rules already loaded + /sbin/pfctl -s nat 2>/dev/null | grep -q 172.17 + if [ $? -eq 0 ] ; then return ; fi + + if [ "${docker_nat_iface}" != "NONE" ] ; then + iface="${docker_nat_iface}" + else + iface=`/usr/bin/netstat -f inet -nrW | grep '^default' | awk '{ print $6 }'` + fi + echo "nat on ${iface} from 172.17.0.0/16 to any -> (${iface})" > /tmp/pf-nat-docker.$$ + /sbin/pfctl -f /tmp/pf-nat-docker.$$ 2>/dev/null + /sbin/pfctl -e 2>/dev/null + rm /tmp/pf-nat-docker.$$ + +} + +docker_stop() +{ + if [ -e "/var/run/docker.pid" ] ; then + echo "Stopping docker..." + pkill -F /var/run/docker.pid + fi +} + +run_rc_command "$1" + Added: head/sysutils/docker/pkg-descr ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/docker/pkg-descr Mon Jul 6 15:37:33 2015 (r391421) @@ -0,0 +1,3 @@ +FreeBSD port of Docker + +WWW: https://github.com/kvasdopil/docker Added: head/sysutils/docker/pkg-message ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/docker/pkg-message Mon Jul 6 15:37:33 2015 (r391421) @@ -0,0 +1,21 @@ + +Docker requires a bit of setup before usage. + +You will need to create a ZFS dataset on /usr/docker + +# zfs create -o mountpoint=/usr/docker /docker + +And lastly enable the docker daemon +# sysrc -f /etc/rc.conf docker_enable="YES" +# service docker start + +(WARNING) + +Starting the docker service will also add the following PF rule: + +nat on ${iface} from 172.17.0.0/16 to any -> (${iface}) + +Where $iface is the default NIC on the system, or the value +of $docker_nat_iface. This is for network connectivity to docker +containers in this early port. This should not be needed in future +versions of docker.