Page MenuHomeFreeBSD

D12270.id32784.diff
No OneTemporary

D12270.id32784.diff

Index: sysutils/docker-freebsd/Makefile
===================================================================
--- sysutils/docker-freebsd/Makefile
+++ sysutils/docker-freebsd/Makefile
@@ -2,36 +2,52 @@
# $FreeBSD$
PORTNAME= docker-freebsd
-PORTVERSION= 20150625
-PORTREVISION= 1
+PORTVERSION= g20170907
+PORTEPOCH= 1
CATEGORIES= sysutils
-MAINTAINER= amutu@amutu.com
+MAINTAINER= lifanov@FreeBSD.org
COMMENT= Docker containment system
LICENSE= APACHE20
-LICENSE_FILE= ${WRKSRC}/LICENSE
+LICENSE_FILE= ${GO_WRKSRC}/LICENSE
-BUILD_DEPENDS= go>=1.4:lang/go \
- bash:shells/bash \
- sqlite3:databases/sqlite3
-RUN_DEPENDS= go>=1.4:lang/go \
- bash:shells/bash \
- sqlite3:databases/sqlite3
+BUILD_DEPENDS= bash:shells/bash
+LIB_DEPENDS= libepoll-shim.so:devel/libepoll-shim
-USE_GITHUB= yes
-GH_ACCOUNT= kvasdopil
+USES= go gmake
+
+USE_GITHUB= nodefault
+GH_ACCOUNT= freebsd-docker
GH_PROJECT= docker
-GH_TAGNAME= 582db78
+GH_TAGNAME= 52d67c9
-PLIST_FILES= bin/docker
+GH_TUPLE= freebsd-docker:docker:52d67c9:docker/src/github.com/docker/docker \
+ freebsd-docker:containerd:00a99ef:containerd/src/github.com/containerd/containerd \
+ freebsd-docker:libnetwork:acb2447:libnetwork/src/github.com/docker/libnetwork \
+ freebsd-docker:runc:9c2d8d1:runc/src/github.com/runc/runc \
+ krallin:tini:v0.16.1:tini/src/github.com/krallin/tini
+
+PLIST_FILES= bin/docker \
+ bin/dockerd \
+ bin/docker-containerd \
+ bin/docker-containerd-ctr \
+ bin/docker-containerd-shim \
+ bin/docker-proxy
USE_RC_SUBR= docker
+GO_PKGNAME= github.com/${GH_PROJECT}/${GH_PROJECT}
+SSP_UNSAFE= yes
+
+post-extract:
+ ${LN} -sf ${WRKSRC}/src ${WRKDIR}
+
do-build:
- @cd ${WRKSRC} && export AUTO_GOPATH=1 && export DOCKER_GITCOMMIT=${GH_TAGNAME} && ./hack/make.sh binary
+ @cd ${GO_WRKSRC} && export DOCKER_GITCOMMIT=${GH_TAGNAME} && ${SETENV} ${MAKE_ENV} ${GO_ENV} ${GMAKE} -f Makefile.freebsd binary
do-install:
- @${MKDIR} ${STAGEDIR}${PREFIX}/bin
- ${INSTALL_PROGRAM} ${WRKSRC}/bundles/latest/binary/docker ${STAGEDIR}${PREFIX}/bin/
+.for f in ${PLIST_FILES}
+ ${INSTALL_PROGRAM} ${GO_WRKSRC}/bundles/${f} ${STAGEDIR}${PREFIX}/bin
+.endfor
.include <bsd.port.mk>
Index: sysutils/docker-freebsd/distinfo
===================================================================
--- sysutils/docker-freebsd/distinfo
+++ sysutils/docker-freebsd/distinfo
@@ -1,2 +1,13 @@
-SHA256 (kvasdopil-docker-20150625-582db78_GH0.tar.gz) = a750d344af4af3d30b1a3373f382ab597a2a7aa4a0bb5c22d650d0c5cc9ac506
-SIZE (kvasdopil-docker-20150625-582db78_GH0.tar.gz) = 7292884
+TIMESTAMP = 1504806100
+SHA256 (freebsd-docker-docker-g20170907-52d67c9_GH0.tar.gz) = b58df6102e4a7885a731472cab9239f985908b2377d0774206315f61df91399c
+SIZE (freebsd-docker-docker-g20170907-52d67c9_GH0.tar.gz) = 7181018
+SHA256 (freebsd-docker-docker-52d67c9_GH0.tar.gz) = b58df6102e4a7885a731472cab9239f985908b2377d0774206315f61df91399c
+SIZE (freebsd-docker-docker-52d67c9_GH0.tar.gz) = 7181018
+SHA256 (freebsd-docker-containerd-00a99ef_GH0.tar.gz) = 98c3b021b56521518049ddc65b9a895ebab21bcd33ed37e86e1e45766c290dfd
+SIZE (freebsd-docker-containerd-00a99ef_GH0.tar.gz) = 1231469
+SHA256 (freebsd-docker-libnetwork-acb2447_GH0.tar.gz) = 4c9ae300c414eba96203f7e797652ee4118820ca6d0e8fbe58698bd3cd0cd8c5
+SIZE (freebsd-docker-libnetwork-acb2447_GH0.tar.gz) = 2407383
+SHA256 (freebsd-docker-runc-9c2d8d1_GH0.tar.gz) = 567c2991ad8933c8913b151e8cf0eb09ac2fb547384dcbc7dd31b4a0c2a819a7
+SIZE (freebsd-docker-runc-9c2d8d1_GH0.tar.gz) = 561862
+SHA256 (krallin-tini-v0.16.1_GH0.tar.gz) = c2b7fe2fb92e71911d06b7571b53d4e7e8985b34efe2a599670b070b000c8dbe
+SIZE (krallin-tini-v0.16.1_GH0.tar.gz) = 29641
Index: sysutils/docker-freebsd/files/docker.in
===================================================================
--- sysutils/docker-freebsd/files/docker.in
+++ sysutils/docker-freebsd/files/docker.in
@@ -9,52 +9,104 @@
name="docker"
rcvar="docker_enable"
+startpre_cmd="docker_precmd"
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_flags=}
+: ${docker_enable:=NO}
+: ${docker_dir:=/usr/docker}
+: ${docker_nat_iface:=NONE}
+: ${docker_flags:=}
+: ${docker_log_file:=/var/log/docker.log}
+: ${docker_zpool_name:=zroot}
+: ${docker_zpool_file:=/usr/local/docker.img}
+: ${docker_zpool_file_size:=4G}
+: ${docker_zfs_name:=docker}
-docker_start()
+docker_precmd()
{
- if [ ! -d "${docker_dir}" ] ; then
- echo "Missing ${docker_dir}! Please create / mount a ZFS dataset at this location."
- exit 1
- fi
+ local fs_type \
+ make_zfs \
+ zfs_mountpoint \
+ zfs_name \
+ zpool_name \
+ zpool_size
- 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
+ for module in zfs pf linux linux64; do
+ kldstat -qm $module || kldload $module || die
+ done
+ [ -d "$docker_dir" ] || mkdir -p "$docker_dir"
- echo "Starting docker..."
- daemon -p /var/run/docker.pid ${command} -d -e jail -s zfs -g ${docker_dir} -D ${docker_flags} >/var/log/docker.log 2>/var/log/docker.log
+ #
+ # If ZFS filesystem is already mounted on $docker_dir, do nothing.
+ # If $docker_dir is inside existing ZFS filesystem,
+ # create new filesystem.
+ #
+ # Otherwise, create $docker_zpool_file to contain pool and filesystem.
+ #
+ fstype=$( df -T "$docker_dir" 2> /dev/null | awk 'NR>1,$0=$2' )
+ case "$fstype" in
+ zfs)
+ zfs_mountpoint=$( zfs get -Ho value mountpoint "$docker_dir" )
+ zfs_name=$( zfs get -Ho name mountpoint "$docker_dir" )
+ [ "$docker_dir" = "$zfs_mountpoint" ] || make_zfs=filesystem
+ ;;
+ *)
+ zfs_name="$docker_zpool_name"
+ make_zfs=pool
+ esac
+ zpool_name="${zfs_name%%/*}"
- # Check for linux 64bit support and enable
- kldstat | grep -q 'linux64'
- if [ $? -ne 0 -a -e "/boot/kernel/linux64.ko" ] ; then
- kldload linux64
+ #
+ # Setup ZFS pool if required
+ #
+ case "$make_zfs" in
+ pool)
+ #
+ # Expand desired pool size to bytes
+ #
+ zpool_size=$( awk -v size="$docker_zpool_file_size" '
+ BEGIN {
+ suffixen = "KMGTPEZYXWV" # ... Yotta Xenna Weka Vendeka
+ size = toupper(size)
+ sub(sprintf("[^[:digit:].%s].*", suffixen), "", size)
+ if (match(size, sprintf("[%s]", suffixen))) {
+ suffix = substr(size, RSTART, 1)
+ size = substr(size, 1, RSTART - 1)
+ match(suffixen, suffix)
+ size = size * 1024 ** RSTART
+ }
+ printf "%i\n", size
+ exit
+ }
+ ' )
+
+ #
+ # Initialize the file using dd(1) piped through dpv(1)
+ #
+ msg="Creating ZFS pool file ($docker_zpool_file_size size) ..."
+ truncate -s "$docker_zpool_file_size" "$docker_zpool_file"
+
+ #
+ # Create zpool
+ #
+ echo "Creating ZFS pool from file $docker_zpool_file ..."
+ zpool create "$docker_zpool_name" "$docker_zpool_file"
+ ;;
+ esac
+
+ #
+ # Setup ZFS filesystem
+ #
+ if [ "$make_zfs" ]; then
+ echo "Creating ZFS filesystem $zpool_name/$docker_zfs_name ..."
+ zfs create -o mountpoint="$docker_dir" \
+ "$zpool_name/$docker_zfs_name"
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
@@ -68,7 +120,25 @@
/sbin/pfctl -f /tmp/pf-nat-docker.$$ 2>/dev/null
/sbin/pfctl -e 2>/dev/null
rm /tmp/pf-nat-docker.$$
+}
+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 ${docker_flags} >${docker_log_file} 2>${docker_log_file}
}
docker_stop()

File Metadata

Mime Type
text/plain
Expires
Mon, Jan 20, 1:47 AM (20 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15969750
Default Alt Text
D12270.id32784.diff (8 KB)

Event Timeline