From 0c8059981247a2b959ba6965221bcaca190684e5 Mon Sep 17 00:00:00 2001 From: Qiang Huang Date: Tue, 30 Aug 2016 09:46:47 +0800 Subject: [PATCH] Combine runctestimage and runcimage There is no need that keep them separate, it also fixes #1006. Signed-off-by: Qiang Huang --- Dockerfile | 47 ++++++++++++++++++++++++++++++++++++++++-- Makefile | 16 +++++++------- script/test_Dockerfile | 44 --------------------------------------- 3 files changed, 52 insertions(+), 55 deletions(-) delete mode 100644 script/test_Dockerfile diff --git a/Dockerfile b/Dockerfile index a25c2210..555eedcc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,46 @@ -FROM runc_test +FROM golang:1.6.2 + +# libseccomp in jessie is not _quite_ new enough -- need backports version +RUN echo 'deb http://httpredir.debian.org/debian jessie-backports main' > /etc/apt/sources.list.d/backports.list + +RUN apt-get update && apt-get install -y \ + build-essential \ + curl \ + gawk \ + iptables \ + pkg-config \ + libaio-dev \ + libcap-dev \ + libprotobuf-dev \ + libprotobuf-c0-dev \ + libseccomp2/jessie-backports \ + libseccomp-dev/jessie-backports \ + protobuf-c-compiler \ + protobuf-compiler \ + python-minimal \ + --no-install-recommends + +# install bats +RUN cd /tmp \ + && git clone https://github.com/sstephenson/bats.git \ + && cd bats \ + && git reset --hard 03608115df2071fff4eaaff1605768c275e5f81f \ + && ./install.sh /usr/local + +# install criu +ENV CRIU_VERSION 1.7 +RUN mkdir -p /usr/src/criu \ + && curl -sSL https://github.com/xemul/criu/archive/v${CRIU_VERSION}.tar.gz | tar -v -C /usr/src/criu/ -xz --strip-components=1 \ + && cd /usr/src/criu \ + && make install-criu + +# setup a playground for us to spawn containers in +ENV ROOTFS /busybox +RUN mkdir -p ${ROOTFS} \ + && curl -o- -sSL 'https://github.com/jpetazzo/docker-busybox/raw/buildroot-2014.11/rootfs.tar' | tar -C ${ROOTFS} -xf - + +COPY script/tmpmount / +WORKDIR /go/src/github.com/opencontainers/runc +ENTRYPOINT ["/tmpmount"] + ADD . /go/src/github.com/opencontainers/runc -RUN make diff --git a/Makefile b/Makefile index a84c5392..9ce84ad7 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,6 @@ BINDIR := $(PREFIX)/sbin GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g") RUNC_IMAGE := runc_dev$(if $(GIT_BRANCH_CLEAN),:$(GIT_BRANCH_CLEAN)) -RUNC_TEST_IMAGE := runc_test$(if $(GIT_BRANCH_CLEAN),:$(GIT_BRANCH_CLEAN)) PROJECT := github.com/opencontainers/runc TEST_DOCKERFILE := script/test_Dockerfile BUILDTAGS := seccomp @@ -33,9 +32,8 @@ static: $(RUNC_LINK) $(RUNC_LINK): ln -sfn $(CURDIR) $(RUNC_LINK) -dbuild: runctestimage - docker build -t $(RUNC_IMAGE) . - docker create --name=$(RUNC_INSTANCE) $(RUNC_IMAGE) +dbuild: runcimage + docker run --name=$(RUNC_INSTANCE) $(RUNC_IMAGE) make docker cp $(RUNC_INSTANCE):$(RUNC_BUILD_PATH) . docker rm $(RUNC_INSTANCE) @@ -46,8 +44,8 @@ lint: man: man/md2man-all.sh -runctestimage: - docker build -t $(RUNC_TEST_IMAGE) -f $(TEST_DOCKERFILE) . +runcimage: + docker build -t $(RUNC_IMAGE) . test: make unittest integration @@ -55,14 +53,14 @@ test: localtest: make localunittest localintegration -unittest: runctestimage - docker run -e TESTFLAGS -ti --privileged --rm -v $(CURDIR):/go/src/$(PROJECT) $(RUNC_TEST_IMAGE) make localunittest +unittest: runcimage + docker run -e TESTFLAGS -ti --privileged --rm -v $(CURDIR):/go/src/$(PROJECT) $(RUNC_IMAGE) make localunittest localunittest: all go test -timeout 3m -tags "$(BUILDTAGS)" ${TESTFLAGS} -v ./... integration: runctestimage - docker run -e TESTFLAGS -t --privileged --rm -v $(CURDIR):/go/src/$(PROJECT) $(RUNC_TEST_IMAGE) make localintegration + docker run -e TESTFLAGS -t --privileged --rm -v $(CURDIR):/go/src/$(PROJECT) $(RUNC_IMAGE) make localintegration localintegration: all bats -t tests/integration${TESTFLAGS} diff --git a/script/test_Dockerfile b/script/test_Dockerfile deleted file mode 100644 index 2b1db320..00000000 --- a/script/test_Dockerfile +++ /dev/null @@ -1,44 +0,0 @@ -FROM golang:1.6.2 - -# libseccomp in jessie is not _quite_ new enough -- need backports version -RUN echo 'deb http://httpredir.debian.org/debian jessie-backports main' > /etc/apt/sources.list.d/backports.list - -RUN apt-get update && apt-get install -y \ - build-essential \ - curl \ - gawk \ - iptables \ - pkg-config \ - libaio-dev \ - libcap-dev \ - libprotobuf-dev \ - libprotobuf-c0-dev \ - libseccomp2/jessie-backports \ - libseccomp-dev/jessie-backports \ - protobuf-c-compiler \ - protobuf-compiler \ - python-minimal \ - --no-install-recommends - -# install bats -RUN cd /tmp \ - && git clone https://github.com/sstephenson/bats.git \ - && cd bats \ - && git reset --hard 03608115df2071fff4eaaff1605768c275e5f81f \ - && ./install.sh /usr/local - -# install criu -ENV CRIU_VERSION 1.7 -RUN mkdir -p /usr/src/criu \ - && curl -sSL https://github.com/xemul/criu/archive/v${CRIU_VERSION}.tar.gz | tar -v -C /usr/src/criu/ -xz --strip-components=1 \ - && cd /usr/src/criu \ - && make install-criu - -# setup a playground for us to spawn containers in -ENV ROOTFS /busybox -RUN mkdir -p ${ROOTFS} \ - && curl -o- -sSL 'https://github.com/jpetazzo/docker-busybox/raw/buildroot-2014.11/rootfs.tar' | tar -C ${ROOTFS} -xf - - -COPY script/tmpmount / -WORKDIR /go/src/github.com/opencontainers/runc -ENTRYPOINT ["/tmpmount"]