diff --git a/components/packaging/image/Dockerfile.engine b/components/packaging/image/Dockerfile.engine index d393faf7f1..9242dcdc67 100644 --- a/components/packaging/image/Dockerfile.engine +++ b/components/packaging/image/Dockerfile.engine @@ -1,13 +1,22 @@ # Common builder -FROM golang:1.10-alpine3.7 as builder - -#COPY hack/dockerfile/binaries-commits / +ARG GO_IMAGE +FROM ${GO_IMAGE} as builder COPY hack/dockerfile/install/tini.installer / COPY hack/dockerfile/install/proxy.installer / -RUN apk --update add bash btrfs-progs-dev gcc libc-dev linux-headers \ - git cmake make ca-certificates libltdl libtool libgcc && \ - grep "_COMMIT=" /*.installer |cut -f2- -d: > /binaries-commits +RUN apt-get update && apt-get install -y \ + bash \ + btrfs-tools \ + ca-certificates \ + cmake \ + gcc \ + git \ + libc-dev \ + libgcc-6-dev \ + libltdl-dev \ + libtool \ + make +RUN grep "_COMMIT=" /*.installer |cut -f2- -d: > /binaries-commits # dockerd FROM builder as dockerd-builder @@ -37,9 +46,9 @@ RUN go build -o /sbin/dockerd \ FROM builder as proxy-builder RUN git clone https://github.com/docker/libnetwork.git /go/src/github.com/docker/libnetwork WORKDIR /go/src/github.com/docker/libnetwork -RUN source /binaries-commits && \ +RUN . /binaries-commits && \ git checkout -q "$LIBNETWORK_COMMIT" && \ - go build -buildmode=pie -ldflags="$PROXY_LDFLAGS" \ + CGO_ENABLED=0 go build -buildmode=pie -ldflags="$PROXY_LDFLAGS" \ -o /sbin/docker-proxy \ github.com/docker/libnetwork/cmd/proxy @@ -47,17 +56,17 @@ RUN source /binaries-commits && \ FROM builder as init-builder RUN git clone https://github.com/krallin/tini.git /tini WORKDIR /tini -RUN source /binaries-commits && \ +RUN . /binaries-commits && \ git checkout -q "$TINI_COMMIT" && \ cmake . && make tini-static && \ cp tini-static /sbin/docker-init # runc FROM builder as runc-builder -RUN apk --update add libseccomp-dev +RUN apt-get install -y libseccomp-dev RUN git clone https://github.com/opencontainers/runc.git /go/src/github.com/opencontainers/runc WORKDIR /go/src/github.com/opencontainers/runc -RUN source /binaries-commits && \ +RUN . /binaries-commits && \ git checkout -q "$RUNC_COMMIT" && \ make BUILDTAGS='seccomp apparmor' static && make install diff --git a/components/packaging/image/Makefile b/components/packaging/image/Makefile index 7718ef11b6..9435288ad5 100644 --- a/components/packaging/image/Makefile +++ b/components/packaging/image/Makefile @@ -2,6 +2,9 @@ SHELL:=/bin/bash ENGINE_DIR:=$(CURDIR)/../../engine CLI_DIR:=$(CURDIR)/../../cli VERSION?=0.0.0-dev +GO_BASE_IMAGE=golang +GO_VERSION:=1.10.3 +GO_IMAGE=$(GO_BASE_IMAGE):$(GO_VERSION) STATIC_VERSION=$(shell ../static/gen-static-ver $(ENGINE_DIR) $(VERSION)) DOCKER_HUB_ORG?=dockereng ARCH=$(shell uname -m) @@ -14,6 +17,7 @@ help: ## show make targets .PHONY: clean clean: ## remove build artifacts + -$(RM) $(ENGINE_DIR)/Dockerfile.engine -docker rmi $(DOCKER_HUB_ORG)/$(ENGINE_IMAGE):$(STATIC_VERSION) -rm -f image-linux @@ -24,17 +28,18 @@ image: image-linux $(ENGINE_DIR)/Dockerfile.engine: cp Dockerfile.engine $(ENGINE_DIR) -# builds across multiple archs because the base images +# builds across multiple archs because the base images # utilize manifests image-linux: $(ENGINE_DIR)/Dockerfile.engine docker build -t $(DOCKER_HUB_ORG)/$(ENGINE_IMAGE):$(STATIC_VERSION).$(ARCH) \ - --build-arg VERSION="$(STATIC_VERSION)" \ - --build-arg GITCOMMIT="$$(cd $(ENGINE_DIR) && git rev-parse --short=7 HEAD)" \ - --build-arg BUILDTIME="$(BUILDTIME)" \ - --build-arg PLATFORM="$(PLATFORM)" \ - --build-arg PRODUCT="$(PRODUCT)" \ - --build-arg DEFAULT_PRODUCT_LICENSE="$(DEFAULT_PRODUCT_LICENSE)" \ - --file $< $(ENGINE_DIR) + --build-arg GO_IMAGE="$(GO_IMAGE)" \ + --build-arg VERSION="$(STATIC_VERSION)" \ + --build-arg GITCOMMIT="$$(cd $(ENGINE_DIR) && git rev-parse --short=7 HEAD)" \ + --build-arg BUILDTIME="$(BUILDTIME)" \ + --build-arg PLATFORM="$(PLATFORM)" \ + --build-arg PRODUCT="$(PRODUCT)" \ + --build-arg DEFAULT_PRODUCT_LICENSE="$(DEFAULT_PRODUCT_LICENSE)" \ + --file $< $(ENGINE_DIR) echo $(DOCKER_HUB_ORG)/$(ENGINE_IMAGE):$(STATIC_VERSION).$(ARCH) > $@ engine-$(ARCH).tar: image-linux