From 1bd44739f9c344112a216193cfe1efd4289360e9 Mon Sep 17 00:00:00 2001 From: Lukas Loesche Date: Thu, 19 Feb 2015 19:56:47 +0100 Subject: [PATCH 1/2] docker support --- Makefile | 9 +++++++++ docker/Dockerfile | 4 ++++ tarball/Dockerfile | 16 ++++++++++++++++ tarball/bap.sh | 25 +++++++++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 tarball/Dockerfile create mode 100755 tarball/bap.sh diff --git a/Makefile b/Makefile index 9ccb2f0b..09ae629d 100644 --- a/Makefile +++ b/Makefile @@ -50,6 +50,15 @@ debian-wheezy-77: packages docker build -t mesosphere/mesosdnsbuilder-debian-wheezy debian-wheezy docker run -v $(OUTPUT):/target mesosphere/mesosdnsbuilder-debian-wheezy bap $(VERSION) +.PHONY: tarball +tarball: packages + docker build -t mesosphere/mesosdnsbuilder-tarball tarball + docker run -v $(OUTPUT):/target mesosphere/mesosdnsbuilder-tarball bap $(VERSION) + +.PHONY: docker +docker: packages + docker build -t mesosphere/mesos-dns docker + .PHONY: clean clean: rm -rf '$(OUTPUT)' diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..11179a51 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,4 @@ +FROM busybox +MAINTAINER Mesosphere Package Builder +ADD mesos-dns*tar.gz / +CMD ["/usr/bin/mesos-dns"] diff --git a/tarball/Dockerfile b/tarball/Dockerfile new file mode 100644 index 00000000..f28bfc68 --- /dev/null +++ b/tarball/Dockerfile @@ -0,0 +1,16 @@ +FROM centos:centos7 +MAINTAINER Mesosphere Package Builder + +RUN yum -y update && \ + yum -y install epel-release && \ + yum -y group install 'Development Tools' && \ + yum -y install golang && \ + yum clean all + +RUN mkdir -p /build/ && \ + mkdir -p /package/root/ && \ + mkdir -p /package/root/usr/bin/ + +COPY bap.sh /usr/bin/bap + +CMD ["bap"] diff --git a/tarball/bap.sh b/tarball/bap.sh new file mode 100755 index 00000000..d553d635 --- /dev/null +++ b/tarball/bap.sh @@ -0,0 +1,25 @@ +#!/bin/sh +version=${1-0.1} +if [ ! -d /target ] +then + echo "output directory /target not found" + exit 1 +fi +mkdir -p /build/ +mkdir -p /package/root/ +mkdir -p /package/root/usr/bin/ +mkdir -p /package/root/lib64/ +export GOPATH=/build +go get github.com/miekg/dns +go get github.com/mesosphere/mesos-dns +cd $GOPATH/src/github.com/mesosphere/mesos-dns +go build -o mesos-dns +strip mesos-dns +cp mesos-dns /package/root/usr/bin/ +cp /lib64/ld-linux-x86-64.so.2 /package/root/lib64/ +cp /lib64/libc.so.6 /package/root/lib64/ +cp /lib64/libpthread.so.0 /package/root/lib64/ +cd /package/root +tar czvf ../mesos-dns_$version-$(date +%Y%m%d%H%M%S).tar.gz . +cd .. +cp mesos-dns*.tar.gz /target/ From c41daed5b1b03339616a275a7be10f732c49703a Mon Sep 17 00:00:00 2001 From: Lukas Loesche Date: Thu, 19 Feb 2015 20:31:08 +0100 Subject: [PATCH 2/2] add docker image support --- Makefile | 12 +++++++----- {tarball => docker-rootfs}/Dockerfile | 10 ++++++++++ {tarball => docker-rootfs}/bap.sh | 8 +++++--- docker-rootfs/etc/group | 11 +++++++++++ docker-rootfs/etc/hostname | 0 docker-rootfs/etc/hosts | 0 docker-rootfs/etc/nsswitch.conf | 4 ++++ docker-rootfs/etc/passwd | 13 +++++++++++++ docker-rootfs/etc/resolv.conf | 0 docker/Dockerfile | 5 +++-- 10 files changed, 53 insertions(+), 10 deletions(-) rename {tarball => docker-rootfs}/Dockerfile (54%) rename {tarball => docker-rootfs}/bap.sh (72%) create mode 100644 docker-rootfs/etc/group create mode 100644 docker-rootfs/etc/hostname create mode 100644 docker-rootfs/etc/hosts create mode 100644 docker-rootfs/etc/nsswitch.conf create mode 100644 docker-rootfs/etc/passwd create mode 100644 docker-rootfs/etc/resolv.conf diff --git a/Makefile b/Makefile index 09ae629d..cb59a260 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ OUTPUT := $(shell pwd)/packages +DOCKER_OUT := $(shell pwd)/docker VERSION ?= 0.1 .PHONY: help @@ -50,18 +51,19 @@ debian-wheezy-77: packages docker build -t mesosphere/mesosdnsbuilder-debian-wheezy debian-wheezy docker run -v $(OUTPUT):/target mesosphere/mesosdnsbuilder-debian-wheezy bap $(VERSION) -.PHONY: tarball -tarball: packages - docker build -t mesosphere/mesosdnsbuilder-tarball tarball - docker run -v $(OUTPUT):/target mesosphere/mesosdnsbuilder-tarball bap $(VERSION) +.PHONY: docker-rootfs +docker-rootfs: + docker build -t mesosphere/mesosdnsbuilder-docker-rootfs docker-rootfs + docker run -v $(DOCKER_OUT):/target mesosphere/mesosdnsbuilder-docker-rootfs bap $(VERSION) .PHONY: docker -docker: packages +docker: docker-rootfs docker build -t mesosphere/mesos-dns docker .PHONY: clean clean: rm -rf '$(OUTPUT)' + rm -f docker/mesos-dns_rootfs.tar.gz packages: mkdir -p '$(OUTPUT)' diff --git a/tarball/Dockerfile b/docker-rootfs/Dockerfile similarity index 54% rename from tarball/Dockerfile rename to docker-rootfs/Dockerfile index f28bfc68..bddc4e34 100644 --- a/tarball/Dockerfile +++ b/docker-rootfs/Dockerfile @@ -9,8 +9,18 @@ RUN yum -y update && \ RUN mkdir -p /build/ && \ mkdir -p /package/root/ && \ + mkdir -p /package/root/etc/ && \ mkdir -p /package/root/usr/bin/ +RUN cd /package/root/etc/ && ln -s /proc/mounts mtab + +COPY etc/group /package/root/etc/ +COPY etc/hostname /package/root/etc/ +COPY etc/hosts /package/root/etc/ +COPY etc/nsswitch.conf /package/root/etc/ +COPY etc/passwd /package/root/etc/ +COPY etc/resolv.conf /package/root/etc/ + COPY bap.sh /usr/bin/bap CMD ["bap"] diff --git a/tarball/bap.sh b/docker-rootfs/bap.sh similarity index 72% rename from tarball/bap.sh rename to docker-rootfs/bap.sh index d553d635..3563a2ed 100755 --- a/tarball/bap.sh +++ b/docker-rootfs/bap.sh @@ -1,5 +1,4 @@ #!/bin/sh -version=${1-0.1} if [ ! -d /target ] then echo "output directory /target not found" @@ -18,8 +17,11 @@ strip mesos-dns cp mesos-dns /package/root/usr/bin/ cp /lib64/ld-linux-x86-64.so.2 /package/root/lib64/ cp /lib64/libc.so.6 /package/root/lib64/ +cp /lib64/libnss_compat.so.2 /package/root/lib64/ +cp /lib64/libnss_dns.so.2 /package/root/lib64/ +cp /lib64/libnss_files.so.2 /package/root/lib64/ cp /lib64/libpthread.so.0 /package/root/lib64/ cd /package/root -tar czvf ../mesos-dns_$version-$(date +%Y%m%d%H%M%S).tar.gz . +tar czvf ../mesos-dns_rootfs.tar.gz . cd .. -cp mesos-dns*.tar.gz /target/ +cp mesos-dns_rootfs.tar.gz /target/ diff --git a/docker-rootfs/etc/group b/docker-rootfs/etc/group new file mode 100644 index 00000000..45906401 --- /dev/null +++ b/docker-rootfs/etc/group @@ -0,0 +1,11 @@ +root:x:0: +bin:x:1: +daemon:x:2: +adm:x:4: +lp:x:7: +mail:x:12: +games:x:20: +ftp:x:50: +nobody:x:99: +users:x:100: +nfsnobody:x:65534: diff --git a/docker-rootfs/etc/hostname b/docker-rootfs/etc/hostname new file mode 100644 index 00000000..e69de29b diff --git a/docker-rootfs/etc/hosts b/docker-rootfs/etc/hosts new file mode 100644 index 00000000..e69de29b diff --git a/docker-rootfs/etc/nsswitch.conf b/docker-rootfs/etc/nsswitch.conf new file mode 100644 index 00000000..ecc16cf5 --- /dev/null +++ b/docker-rootfs/etc/nsswitch.conf @@ -0,0 +1,4 @@ +passwd: files +shadow: files +group: files +hosts: files dns diff --git a/docker-rootfs/etc/passwd b/docker-rootfs/etc/passwd new file mode 100644 index 00000000..c1da9487 --- /dev/null +++ b/docker-rootfs/etc/passwd @@ -0,0 +1,13 @@ +root:x:0:0:root:/root:/bin/bash +bin:x:1:1:bin:/bin:/sbin/nologin +daemon:x:2:2:daemon:/sbin:/sbin/nologin +adm:x:3:4:adm:/var/adm:/sbin/nologin +lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin +sync:x:5:0:sync:/sbin:/bin/sync +shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown +halt:x:7:0:halt:/sbin:/sbin/halt +mail:x:8:12:mail:/var/spool/mail:/sbin/nologin +operator:x:11:0:operator:/root:/sbin/nologin +games:x:12:100:games:/usr/games:/sbin/nologin +ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin +nobody:x:99:99:Nobody:/:/sbin/nologin diff --git a/docker-rootfs/etc/resolv.conf b/docker-rootfs/etc/resolv.conf new file mode 100644 index 00000000..e69de29b diff --git a/docker/Dockerfile b/docker/Dockerfile index 11179a51..e4203a75 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,5 @@ -FROM busybox +FROM scratch MAINTAINER Mesosphere Package Builder -ADD mesos-dns*tar.gz / +ADD mesos-dns_rootfs.tar.gz / + CMD ["/usr/bin/mesos-dns"]