From f29cd6f3de7c2f7aec140bc9d4d8ceb25cc5921d Mon Sep 17 00:00:00 2001 From: FreddieOliveira Date: Sun, 17 Jan 2021 01:42:16 -0300 Subject: [PATCH] Add dockerd package --- root-packages/dockerd/build.sh | 30 ++++++++++++++++++++++++++++++ root-packages/dockerd/daemon.json | 9 +++++++++ root-packages/dockerd/dockerd | 30 ++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 root-packages/dockerd/build.sh create mode 100644 root-packages/dockerd/daemon.json create mode 100755 root-packages/dockerd/dockerd diff --git a/root-packages/dockerd/build.sh b/root-packages/dockerd/build.sh new file mode 100644 index 000000000..effa1fed2 --- /dev/null +++ b/root-packages/dockerd/build.sh @@ -0,0 +1,30 @@ +TERMUX_PKG_HOMEPAGE=https://docs.docker.com/engine/ +TERMUX_PKG_DESCRIPTION="Server daemon process for building and containerizing applications." +TERMUX_PKG_LICENSE="Apache-2.0" +TERMUX_PKG_MAINTAINER="@termux" +TERMUX_PKG_VERSION=20.10.2 +TERMUX_PKG_SRCURL=https://github.com/moby/moby/archive/v${TERMUX_PKG_VERSION}.tar.gz +TERMUX_PKG_SHA256=dc4818f0cba2ded2f6f7420a1fda027ddbf6c6c9fe319f84d1311bfe610447ca +#TERMUX_PKG_DEPENDS="containerd" +#TERMUX_PKG_BLACKLISTED_ARCHES="arm, i686, x86_64" + +termux_step_make() { + # setup go build environment + termux_setup_golang + + # apply some patches in a batch + xargs sed -i "s_\(/etc/docker\)_$PREFIX\1_g" < <(grep -R /etc/docker | cut -d':' -f1 | sort | uniq) + xargs sed -i 's/[a-zA-Z0-9]*\.GOOS/"linux"/g' < <(grep -R '[a-zA-Z0-9]*\.GOOS' | cut -d':' -f1 | sort | uniq) + + + # issue the build command + export DOCKER_GITCOMMIT=8891c58a43 + export DOCKER_BUILDTAGS='exclude_graphdriver_btrfs exclude_graphdriver_devicemapper exclude_graphdriver_quota selinux exclude_graphdriver_aufs' + while ! files=$(AUTO_GOPATH=1 PREFIX='' hack/make.sh dynbinary 2>&1 1>/dev/null); do xargs sed -i 's/\("runtime"\)/_ \1/' < <(echo $files | grep runtime | cut -d':' -f1 | cut -c38-); done +} + +termux_step_make_install() { + install -Dm 0700 bundles/dynbinary-daemon/dockerd-dev ${TERMUX_PREFIX}/bin/dockerd-dev + install -Dm 0700 ${TERMUX_PKG_BUILDER_DIR}/dockerd ${TERMUX_PREFIX}/bin/dockerd + install -Dm 0700 ${TERMUX_PKG_BUILDER_DIR}/daemon.json ${TERMUX_PREFIX}/etc/docker/daemon.json +} diff --git a/root-packages/dockerd/daemon.json b/root-packages/dockerd/daemon.json new file mode 100644 index 000000000..8e3e87432 --- /dev/null +++ b/root-packages/dockerd/daemon.json @@ -0,0 +1,9 @@ +{ + "data-root": "/data/docker/lib/docker", + "exec-root": "/data/docker/run/docker", + "pidfile": "/data/docker/run/docker.pid", + "hosts": [ + "unix:///data/docker/run/docker.sock" + ], + "storage-driver": "overlay2" +} diff --git a/root-packages/dockerd/dockerd b/root-packages/dockerd/dockerd new file mode 100755 index 000000000..ed8f533aa --- /dev/null +++ b/root-packages/dockerd/dockerd @@ -0,0 +1,30 @@ +#!/data/data/com.termux/files/usr/bin/bash + +export PATH="${PATH}:/system/xbin:/system/bin" +opts='rw,nosuid,nodev,noexec,relatime' +cgroups='blkio cpu cpuacct cpuset devices freezer memory pids schedtune' + +# try to mount cgroup root dir and exit in case of failure +if ! mountpoint -q /sys/fs/cgroup 2>/dev/null; then + mkdir -p /sys/fs/cgroup + mount -t tmpfs -o "${opts}" cgroup_root /sys/fs/cgroup || exit +fi + +# try to mount cgroup2 +if ! mountpoint -q /sys/fs/cgroup/cg2_bpf 2>/dev/null; then + mkdir -p /sys/fs/cgroup/cg2_bpf + mount -t cgroup2 -o "${opts}" cgroup2_root /sys/fs/cgroup/cg2_bpf +fi + +# try to mount differents cgroups +for cg in ${cgroups}; do + if ! mountpoint -q "/sys/fs/cgroup/${cg}" 2>/dev/null; then + mkdir -p "/sys/fs/cgroup/${cg}" + mount -t cgroup -o "${opts},${cg}" "${cg}" "/sys/fs/cgroup/${cg}" \ + || rmdir "/sys/fs/cgroup/${cg}" + fi +done + +# start the docker daemon +dockerd-dev $@ +