From 5c501c8ec8812fbf8027bc9f46ed635ff15d96e6 Mon Sep 17 00:00:00 2001 From: Bruce Ashfield Date: Sat, 11 Mar 2017 23:37:36 -0500 Subject: docker-registry: provide via docker-distribution Follow the bouncing docker-registry package. Rather than use the docker hub registry container, we can have finer grained control if we clone and build the docker-distribution repository directly. Since this is distinct from the main docker package/codebase, we break the registry back out into its own package. We also create a baseline configuration and .service file that can be the basis for more complex implementations. Signed-off-by: Bruce Ashfield --- .../docker-distribution/docker-distribution_git.bb | 65 ++++++++++++++++++++++ .../files/docker-registry.service | 10 ++++ recipes-containers/docker/docker_git.bb | 12 +--- 3 files changed, 77 insertions(+), 10 deletions(-) create mode 100644 recipes-containers/docker-distribution/docker-distribution_git.bb create mode 100644 recipes-containers/docker-distribution/files/docker-registry.service diff --git a/recipes-containers/docker-distribution/docker-distribution_git.bb b/recipes-containers/docker-distribution/docker-distribution_git.bb new file mode 100644 index 00000000..e86d4ff9 --- /dev/null +++ b/recipes-containers/docker-distribution/docker-distribution_git.bb @@ -0,0 +1,65 @@ +HOMEPAGE = "http://github.com/docker/distribution" +SUMMARY = "The Docker toolset to pack, ship, store, and deliver content" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=d2794c0df5b907fdace235a619d80314" + +DEPENDS = "go-cross-${TARGET_ARCH} \ + " + +SRCREV_distribution="0810eba2adf048b77621472991211924d9ec31c5" +SRC_URI = "git://github.com/docker/distribution.git;branch=master;name=distribution;destsuffix=git/src/github.com/docker/distribution \ + file://docker-registry.service \ + " + +PACKAGES =+ "docker-registry" + +PV = "v2.6.0-rc+git${SRCPV}" +S = "${WORKDIR}/git/src/github.com/docker/distribution" + +inherit go-osarchmap + +# This disables seccomp and apparmor, which are on by default in the +# go package. +EXTRA_OEMAKE="BUILDTAGS=''" + +do_compile() { + export GOARCH="${TARGET_GOARCH}" + export GOPATH="${WORKDIR}/git/" + + # Pass the needed cflags/ldflags so that cgo + # can find the needed headers files and libraries + export CGO_ENABLED="1" + export CFLAGS="" + export LDFLAGS="" + export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}" + export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" + + oe_runmake binaries +} + +do_install() { + install -d ${D}/${sbindir} + install ${S}/bin/registry ${D}/${sbindir} + + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then + install -d ${D}${systemd_unitdir}/system + install -m 644 ${WORKDIR}/docker-registry.service ${D}/${systemd_unitdir}/system + fi + + install -d ${D}/${sysconfdir}/docker-distribution/registry/ + install ${S}/cmd/registry/config-example.yml ${D}/${sysconfdir}/docker-distribution/registry/config.yml + + # storage for the registry containers + install -d ${D}/${localstatedir}/lib/registry/ +} + +INSANE_SKIP_${PN} += "ldflags already-stripped" +INSANE_SKIP_docker-registry += "ldflags already-stripped" + +FILES_docker-registry = "${sbindir}/*" +FILES_docker-registry += "${systemd_unitdir}/system/docker-registry.service" +FILES_docker-registry += "${sysconfdir}/docker-distribution/*" +FILES_docker-registry += "${localstatedir}/lib/registry/" + +SYSTEMD_SERVICE_docker-registry = "${@bb.utils.contains('DISTRO_FEATURES','systemd','docker-registry.service','',d)}" +SYSTEMD_AUTO_ENABLE_docker-registry = "enable" diff --git a/recipes-containers/docker-distribution/files/docker-registry.service b/recipes-containers/docker-distribution/files/docker-registry.service new file mode 100644 index 00000000..15460c7a --- /dev/null +++ b/recipes-containers/docker-distribution/files/docker-registry.service @@ -0,0 +1,10 @@ +[Unit] +Description=v2 Registry server for Docker + +[Service] +Type=simple +ExecStart=/usr/sbin/registry serve /etc/docker-distribution/registry/config.yml +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/recipes-containers/docker/docker_git.bb b/recipes-containers/docker/docker_git.bb index bad3d866..246fbfeb 100644 --- a/recipes-containers/docker/docker_git.bb +++ b/recipes-containers/docker/docker_git.bb @@ -24,7 +24,6 @@ SRC_URI = "\ git://github.com/docker/docker.git;nobranch=1;name=docker \ git://github.com/docker/libnetwork.git;branch=master;name=libnetwork;destsuffix=libnetwork \ file://docker.init \ - file://docker-registry.service \ file://hi.Dockerfile \ file://context-use-golang.org-x-net-pkg-until-we-move-to-go.patch \ " @@ -60,7 +59,7 @@ DEPENDS = " \ grpc-go \ " -PACKAGES =+ "${PN}-contrib ${PN}-registry" +PACKAGES =+ "${PN}-contrib" DEPENDS_append_class-target = "lvm2" RDEPENDS_${PN} = "curl aufs-util git util-linux iptables \ @@ -69,7 +68,7 @@ RDEPENDS_${PN} = "curl aufs-util git util-linux iptables \ RDEPENDS_${PN} += "virtual/containerd virtual/runc" RRECOMMENDS_${PN} = "kernel-module-dm-thin-pool kernel-module-nf-nat" -RSUGGESTS_${PN} = "lxc docker-registry rt-tests" +RSUGGESTS_${PN} = "lxc rt-tests" DOCKER_PKG="github.com/docker/docker" do_configure[noexec] = "1" @@ -136,9 +135,7 @@ inherit systemd update-rc.d SYSTEMD_PACKAGES = "${@bb.utils.contains('DISTRO_FEATURES','systemd','${PN}','',d)}" SYSTEMD_SERVICE_${PN} = "${@bb.utils.contains('DISTRO_FEATURES','systemd','docker.service','',d)}" -SYSTEMD_SERVICE_${PN}-registry = "${@bb.utils.contains('DISTRO_FEATURES','systemd','docker-registry.service','',d)}" -SYSTEMD_AUTO_ENABLE_${PN}-registry = "enable" SYSTEMD_AUTO_ENABLE_${PN} = "enable" INITSCRIPT_PACKAGES += "${@bb.utils.contains('DISTRO_FEATURES','sysvinit','${PN}','',d)}" @@ -156,8 +153,6 @@ do_install() { install -m 644 ${S}/contrib/init/systemd/docker.* ${D}/${systemd_unitdir}/system # replaces one copied from above with one that uses the local registry for a mirror install -m 644 ${S}/contrib/init/systemd/docker.service ${D}/${systemd_unitdir}/system - - install -m 644 ${WORKDIR}/docker-registry.service ${D}/${systemd_unitdir}/system else install -d ${D}${sysconfdir}/init.d install -m 0755 ${WORKDIR}/docker.init ${D}${sysconfdir}/init.d/docker.init @@ -172,9 +167,6 @@ inherit useradd USERADD_PACKAGES = "${PN}" GROUPADD_PARAM_${PN} = "-r docker" -FILES_${PN}-registry += "${systemd_unitdir}/system/docker-registry.service" -RDEPENDS_${PN}-registry += "docker" - FILES_${PN} += "${systemd_unitdir}/system/*" FILES_${PN}-contrib += "${datadir}/docker/check-config.sh" -- cgit v1.2.3-54-g00ecf