From da41cb3e1940f9afed7eee420f54852727fc25c1 Mon Sep 17 00:00:00 2001 From: Ricardo Carrillo Cruz Date: Mon, 8 Mar 2021 17:59:44 +0100 Subject: [PATCH] Add Dockerfile and make target There is no clear Dockerfile or easy way to build a local docker image. This patch allows to run 'make docker' and it will use a multi-stage Dockerfile inspired by the CI Dockerfile for the build. It allows to use DOCKER_IMAGE and DOCKER_TAG, which are defined on .mk/dist for docker-image target, which is not great for local development since the build runs on the host, not in container. --- Dockerfile | 18 ++++++++++++++++++ Makefile | 4 ++++ 2 files changed, 22 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..c1da488c6d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM ubuntu:20.04 as builder +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get -y update \ + && apt-get -y install build-essential git-core golang npm openvswitch-common libpcap0.8 libpcap0.8-dev libxml2-dev protobuf-compiler libprotobuf-dev libvirt-dev \ + && rm -rf /var/lib/apt/lists/* +WORKDIR /go/src/github.com/skydive-project/skydive +COPY . . +ARG GOPATH=/go +RUN make build + +FROM ubuntu:20.04 as skydive +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get -y update \ + && apt-get -y install golang npm openvswitch-common libpcap0.8 libvirt0 \ + && rm -rf /var/lib/apt/lists/* +COPY --from=builder /go/src/github.com/skydive-project/skydive/skydive /usr/bin/skydive +COPY contrib/docker/skydive.yml /etc/skydive.yml +ENTRYPOINT ["/usr/bin/skydive", "--conf", "/etc/skydive.yml"] diff --git a/Makefile b/Makefile index 4e31ba3e53..418eb4aa22 100644 --- a/Makefile +++ b/Makefile @@ -166,3 +166,7 @@ touchlocalfiles: .proto.touch .typescript.touch .bindata.touch .gendecoder.touch .PHONY: clean clean: skydive.clean test.functionals.clean contribs.clean .ebpf.clean .easyjson.clean .proto.clean .gendecoder.clean .typescript.clean .vppbinapi.clean swagger.clean go clean -i >/dev/null 2>&1 || true + +.PHONY: docker +docker: + docker build . -t $(DOCKER_IMAGE):$(DOCKER_TAG)