Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #154 from seemethere/fix_up_dockerfile
Browse files Browse the repository at this point in the history
Fix up Dockerfile.engine to compile docker-proxy statically
  • Loading branch information
seemethere authored Aug 23, 2018
2 parents 6e21a50 + 5eaeeeb commit 8f1a3c9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
31 changes: 20 additions & 11 deletions image/Dockerfile.engine
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -37,27 +46,27 @@ 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

# docker-init - TODO move this out, last time we bumped was 2016!
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

Expand Down
21 changes: 13 additions & 8 deletions image/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 8f1a3c9

Please sign in to comment.