Skip to content

Commit

Permalink
Use image artifacts as daemon and dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Eli Uriegas <[email protected]>
  • Loading branch information
seemethere committed Sep 19, 2018
1 parent 4235011 commit 2299607
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 135 deletions.
36 changes: 6 additions & 30 deletions deb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ BUILD?=docker build \
$(BUILD_IMAGE_FLAG) \
--build-arg GO_IMAGE=$(GO_IMAGE) \
--build-arg COMMON_FILES=$(COMMON_FILES) \
--build-arg CONTAINERD_SHIM_PROCESS_IMAGE=$(CONTAINERD_SHIM_PROCESS_IMAGE) \
--build-arg ENGINE_IMAGE="$(shell cat sources/engine-image)" \
-t debbuild-$@/$(ARCH) \
-f $(CURDIR)/$@/Dockerfile .
RUN=docker run --rm -i \
Expand All @@ -32,12 +32,8 @@ RUN=docker run --rm -i \
-v $(CURDIR)/debbuild/$@:/build \
debbuild-$@/$(ARCH)

SOURCE_FILES=containerd-proxy.tgz cli.tgz docker.service dockerd.json engine.tar
SOURCE_FILES=engine-image cli.tgz docker.service
SOURCES=$(addprefix sources/, $(SOURCE_FILES))
ENGINE_IMAGE=docker/engine-community
ENGINE_SCOPE=ce

IMAGE_TAG=nightly

.PHONY: help
help: ## show make targets
Expand All @@ -49,9 +45,7 @@ clean: ## remove build artifacts
$(RM) -r debbuild
[ ! -d sources ] || $(CHOWN) -R $(shell id -u):$(shell id -g) sources
$(RM) -r sources
[ ! -d artifacts ] || $(CHOWN) -R $(shell id -u):$(shell id -g) artifacts
$(RM) -r artifacts
-docker rm docker2oci
$(RM) engine-image

engine-$(ARCH).tar:
$(MAKE) -C ../image image-linux
Expand Down Expand Up @@ -133,29 +127,11 @@ sources/cli.tgz:
alpine \
tar -C / -c -z -f /v/cli.tgz --exclude .git cli

sources/containerd-proxy.tgz:
mkdir -p tmp/
curl -fL -o tmp/containerd-proxy.tgz "https://github.com/crosbymichael/containerd-proxy/archive/$(CONTAINERD_PROXY_COMMIT).tar.gz"
tar xzf tmp/containerd-proxy.tgz -C tmp/
mv tmp/containerd-proxy-$(CONTAINERD_PROXY_COMMIT) tmp/containerd-proxy
mkdir -p $(@D)
$(CHOWN) -R $(shell id -u):$(shell id -g) $$(dirname $(@D))
tar -zcf $@ -C tmp/ containerd-proxy
rm -rf tmp/

sources/docker.service: ../systemd/docker.service
mkdir -p $(@D)
cp $< $@

sources/dockerd.json: ../common/dockerd.json
sources/engine-image:
mkdir -p $(@D)
sed \
-e 's!$${ENGINE_IMAGE}!$(ENGINE_IMAGE)!' \
-e 's!$${ENGINE_SCOPE}!$(ENGINE_SCOPE)!' \
-e 's/$${IMAGE_TAG}/$(IMAGE_TAG)/' \
$< > $@

# offline bundle
sources/engine.tar:
$(MAKE) -C ../image ENGINE_IMAGE=$(ENGINE_IMAGE) ENGINE_SCOPE=$(ENGINE_SCOPE) engine-$(ARCH).tar
mv ../image/engine-$(ARCH).tar $@
$(MAKE) -C ../image image-linux
cp ../image/image-linux $@
14 changes: 5 additions & 9 deletions deb/common/rules
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ override_dh_gencontrol:
override_dh_auto_build:
cd /go/src/github.com/docker/cli && \
LDFLAGS='' DISABLE_WARN_OUTSIDE_CONTAINER=1 make VERSION=$(VERSION) GITCOMMIT=$(DOCKER_GITCOMMIT) dynbinary manpages
cd /go/src/github.com/crosbymichael/containerd-proxy && \
make SCOPE_LABEL="com.docker/containerd-proxy.scope" ANY_SCOPE="ee" bin/containerd-proxy

override_dh_strip:
# Go has lots of problems with stripping, so just don't
Expand All @@ -22,20 +20,18 @@ override_dh_auto_install:
install -D -m 0644 /go/src/github.com/docker/cli/contrib/completion/zsh/_docker debian/docker-ce-cli/usr/share/zsh/vendor-completions/_docker
install -D -m 0755 /go/src/github.com/docker/cli/build/docker debian/docker-ce-cli/usr/bin/docker
# docker-ce install
install -D -m 0755 /go/src/github.com/crosbymichael/containerd-proxy/bin/containerd-proxy debian/docker-ce/usr/bin/dockerd
install -D -m 0644 /containerd-shim-process-v1 debian/docker-ce/usr/sbin/containerd-shim-process-v1
install -D -m 0644 /sources/engine.tar debian/docker-ce/var/lib/docker-engine/engine.tar
install -D -m 0644 /sources/docker.service debian/docker-ce/lib/systemd/system/docker.service
install -D -m 0644 /sources/dockerd.json debian/docker-ce/etc/containerd-proxy/dockerd.json
install -D -m 0755 /source/dockerd debian/docker-ce/usr/bin/dockerd
install -D -m 0755 /source/docker-proxy debian/docker-ce/usr/bin/docker-proxy
install -D -m 0755 /source/docker-init debian/docker-ce/usr/bin/docker-init

override_dh_shlibdeps:
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info

override_dh_install:
dh_install
# TODO Can we do this from within our container?
dh_apparmor --profile-name=docker-ce -pdocker-ce

override_dh_shlibdeps:
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info

%:
dh $@ --with=bash-completion $(shell command -v dh_systemd_enable > /dev/null 2>&1 && echo --with=systemd)
9 changes: 5 additions & 4 deletions deb/debian-buster/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ARG GO_IMAGE
ARG CONTAINERD_SHIM_PROCESS_IMAGE
ARG BUILD_IMAGE=debian:buster
ARG ENGINE_IMAGE
FROM ${GO_IMAGE} as golang
FROM ${CONTAINERD_SHIM_PROCESS_IMAGE} as shim-process
FROM ${ENGINE_IMAGE} as engine

FROM ${BUILD_IMAGE}

Expand All @@ -21,15 +21,16 @@ RUN mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-reco
# Copy our sources and untar them
COPY sources/ /sources
RUN mkdir -p /go/src/github.com/docker/ && tar -xzf /sources/cli.tgz -C /go/src/github.com/docker/
RUN mkdir -p /go/src/github.com/crosbymichael && tar -xzf /sources/containerd-proxy.tgz -C /go/src/github.com/crosbymichael

RUN ln -snf /go/src/github.com/docker/cli /root/build-deb/cli

ENV DISTRO debian
ENV SUITE buster

COPY --from=golang /usr/local/go /usr/local/go
COPY --from=shim-process /bin/containerd-shim-process-v1 /containerd-shim-process-v1
COPY --from=engine /sbin/dockerd /source/
COPY --from=engine /sbin/docker-proxy /source/
COPY --from=engine /sbin/docker-init /source/

WORKDIR /root/build-deb
COPY build-deb /root/build-deb/build-deb
Expand Down
9 changes: 5 additions & 4 deletions deb/debian-jessie/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ARG GO_IMAGE
ARG CONTAINERD_SHIM_PROCESS_IMAGE
ARG ENGINE_IMAGE
ARG BUILD_IMAGE=debian:jessie
FROM ${GO_IMAGE} as golang
FROM ${CONTAINERD_SHIM_PROCESS_IMAGE} as shim-process
FROM ${ENGINE_IMAGE} as engine

FROM ${BUILD_IMAGE}

Expand All @@ -21,15 +21,16 @@ RUN mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-reco
# Copy our sources and untar them
COPY sources/ /sources
RUN mkdir -p /go/src/github.com/docker/ && tar -xzf /sources/cli.tgz -C /go/src/github.com/docker/
RUN mkdir -p /go/src/github.com/crosbymichael && tar -xzf /sources/containerd-proxy.tgz -C /go/src/github.com/crosbymichael

RUN ln -snf /go/src/github.com/docker/cli /root/build-deb/cli

ENV DISTRO debian
ENV SUITE jessie

COPY --from=golang /usr/local/go /usr/local/go
COPY --from=shim-process /bin/containerd-shim-process-v1 /containerd-shim-process-v1
COPY --from=engine /sbin/dockerd /source/
COPY --from=engine /sbin/docker-proxy /source/
COPY --from=engine /sbin/docker-init /source/

WORKDIR /root/build-deb
COPY build-deb /root/build-deb/build-deb
Expand Down
9 changes: 5 additions & 4 deletions deb/debian-stretch/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ARG GO_IMAGE
ARG CONTAINERD_SHIM_PROCESS_IMAGE
ARG ENGINE_IMAGE
ARG BUILD_IMAGE=debian:stretch
FROM ${GO_IMAGE} as golang
FROM ${CONTAINERD_SHIM_PROCESS_IMAGE} as shim-process
FROM ${ENGINE_IMAGE} as engine

FROM ${BUILD_IMAGE}

Expand All @@ -21,15 +21,16 @@ RUN mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-reco
# Copy our sources and untar them
COPY sources/ /sources
RUN mkdir -p /go/src/github.com/docker/ && tar -xzf /sources/cli.tgz -C /go/src/github.com/docker/
RUN mkdir -p /go/src/github.com/crosbymichael && tar -xzf /sources/containerd-proxy.tgz -C /go/src/github.com/crosbymichael

RUN ln -snf /go/src/github.com/docker/cli /root/build-deb/cli

ENV DISTRO debian
ENV SUITE stretch

COPY --from=golang /usr/local/go /usr/local/go
COPY --from=shim-process /bin/containerd-shim-process-v1 /containerd-shim-process-v1
COPY --from=engine /sbin/dockerd /source/
COPY --from=engine /sbin/docker-proxy /source/
COPY --from=engine /sbin/docker-init /source/

WORKDIR /root/build-deb
COPY build-deb /root/build-deb/build-deb
Expand Down
9 changes: 5 additions & 4 deletions deb/raspbian-jessie/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ARG GO_IMAGE
ARG CONTAINERD_SHIM_PROCESS_IMAGE
ARG ENGINE_IMAGE
ARG BUILD_IMAGE=resin/rpi-raspbian:jessie
FROM ${GO_IMAGE} as golang
FROM ${CONTAINERD_SHIM_PROCESS_IMAGE} as shim-process
FROM ${ENGINE_IMAGE} as engine

FROM ${BUILD_IMAGE}

Expand All @@ -21,15 +21,16 @@ RUN mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-reco
# Copy our sources and untar them
COPY sources/ /sources
RUN mkdir -p /go/src/github.com/docker/ && tar -xzf /sources/cli.tgz -C /go/src/github.com/docker/
RUN mkdir -p /go/src/github.com/crosbymichael && tar -xzf /sources/containerd-proxy.tgz -C /go/src/github.com/crosbymichael

RUN ln -snf /go/src/github.com/docker/cli /root/build-deb/cli

ENV DISTRO raspbian
ENV SUITE jessie

COPY --from=golang /usr/local/go /usr/local/go
COPY --from=shim-process /bin/containerd-shim-process-v1 /containerd-shim-process-v1
COPY --from=engine /sbin/dockerd /source/
COPY --from=engine /sbin/docker-proxy /source/
COPY --from=engine /sbin/docker-init /source/

WORKDIR /root/build-deb
COPY build-deb /root/build-deb/build-deb
Expand Down
9 changes: 5 additions & 4 deletions deb/raspbian-stretch/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ARG GO_IMAGE
ARG CONTAINERD_SHIM_PROCESS_IMAGE
ARG ENGINE_IMAGE
ARG BUILD_IMAGE=resin/rpi-raspbian:stretch
FROM ${GO_IMAGE} as golang
FROM ${CONTAINERD_SHIM_PROCESS_IMAGE} as shim-process
FROM ${ENGINE_IMAGE} as engine

FROM ${BUILD_IMAGE}

Expand All @@ -21,15 +21,16 @@ RUN mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-reco
# Copy our sources and untar them
COPY sources/ /sources
RUN mkdir -p /go/src/github.com/docker/ && tar -xzf /sources/cli.tgz -C /go/src/github.com/docker/
RUN mkdir -p /go/src/github.com/crosbymichael && tar -xzf /sources/containerd-proxy.tgz -C /go/src/github.com/crosbymichael

RUN ln -snf /go/src/github.com/docker/cli /root/build-deb/cli

ENV DISTRO raspbian
ENV SUITE stretch

COPY --from=golang /usr/local/go /usr/local/go
COPY --from=shim-process /bin/containerd-shim-process-v1 /containerd-shim-process-v1
COPY --from=engine /sbin/dockerd /source/
COPY --from=engine /sbin/docker-proxy /source/
COPY --from=engine /sbin/docker-init /source/

WORKDIR /root/build-deb
COPY build-deb /root/build-deb/build-deb
Expand Down
9 changes: 5 additions & 4 deletions deb/ubuntu-bionic/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ARG GO_IMAGE
ARG CONTAINERD_SHIM_PROCESS_IMAGE
ARG ENGINE_IMAGE
ARG BUILD_IMAGE=ubuntu:bionic
FROM ${GO_IMAGE} as golang
FROM ${CONTAINERD_SHIM_PROCESS_IMAGE} as shim-process
FROM ${ENGINE_IMAGE} as engine

FROM ${BUILD_IMAGE}

Expand All @@ -21,15 +21,16 @@ RUN mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-reco
# Copy our sources and untar them
COPY sources/ /sources
RUN mkdir -p /go/src/github.com/docker/ && tar -xzf /sources/cli.tgz -C /go/src/github.com/docker/
RUN mkdir -p /go/src/github.com/crosbymichael && tar -xzf /sources/containerd-proxy.tgz -C /go/src/github.com/crosbymichael

RUN ln -snf /go/src/github.com/docker/cli /root/build-deb/cli

ENV DISTRO ubuntu
ENV SUITE bionic

COPY --from=golang /usr/local/go /usr/local/go
COPY --from=shim-process /bin/containerd-shim-process-v1 /containerd-shim-process-v1
COPY --from=engine /sbin/dockerd /source/
COPY --from=engine /sbin/docker-proxy /source/
COPY --from=engine /sbin/docker-init /source/

WORKDIR /root/build-deb
COPY build-deb /root/build-deb/build-deb
Expand Down
9 changes: 5 additions & 4 deletions deb/ubuntu-trusty/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ARG GO_IMAGE
ARG CONTAINERD_SHIM_PROCESS_IMAGE
ARG ENGINE_IMAGE
ARG BUILD_IMAGE=ubuntu:trusty
FROM ${GO_IMAGE} as golang
FROM ${CONTAINERD_SHIM_PROCESS_IMAGE} as shim-process
FROM ${ENGINE_IMAGE} as engine

FROM ${BUILD_IMAGE}

Expand All @@ -21,15 +21,16 @@ RUN mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-reco
# Copy our sources and untar them
COPY sources/ /sources
RUN mkdir -p /go/src/github.com/docker/ && tar -xzf /sources/cli.tgz -C /go/src/github.com/docker/
RUN mkdir -p /go/src/github.com/crosbymichael && tar -xzf /sources/containerd-proxy.tgz -C /go/src/github.com/crosbymichael

RUN ln -snf /go/src/github.com/docker/cli /root/build-deb/cli

ENV DISTRO ubuntu
ENV SUITE trusty

COPY --from=golang /usr/local/go /usr/local/go
COPY --from=shim-process /bin/containerd-shim-process-v1 /containerd-shim-process-v1
COPY --from=engine /sbin/dockerd /source/
COPY --from=engine /sbin/docker-proxy /source/
COPY --from=engine /sbin/docker-init /source/

WORKDIR /root/build-deb
COPY build-deb /root/build-deb/build-deb
Expand Down
9 changes: 5 additions & 4 deletions deb/ubuntu-xenial/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ARG GO_IMAGE
ARG CONTAINERD_SHIM_PROCESS_IMAGE
ARG ENGINE_IMAGE
ARG BUILD_IMAGE=ubuntu:xenial
FROM ${GO_IMAGE} as golang
FROM ${CONTAINERD_SHIM_PROCESS_IMAGE} as shim-process
FROM ${ENGINE_IMAGE} as engine

FROM ${BUILD_IMAGE}

Expand All @@ -21,15 +21,16 @@ RUN mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-reco
# Copy our sources and untar them
COPY sources/ /sources
RUN mkdir -p /go/src/github.com/docker/ && tar -xzf /sources/cli.tgz -C /go/src/github.com/docker/
RUN mkdir -p /go/src/github.com/crosbymichael && tar -xzf /sources/containerd-proxy.tgz -C /go/src/github.com/crosbymichael

RUN ln -snf /go/src/github.com/docker/cli /root/build-deb/cli

ENV DISTRO ubuntu
ENV SUITE xenial

COPY --from=golang /usr/local/go /usr/local/go
COPY --from=shim-process /bin/containerd-shim-process-v1 /containerd-shim-process-v1
COPY --from=engine /sbin/dockerd /source/
COPY --from=engine /sbin/docker-proxy /source/
COPY --from=engine /sbin/docker-init /source/

WORKDIR /root/build-deb
COPY build-deb /root/build-deb/build-deb
Expand Down
12 changes: 6 additions & 6 deletions image/Dockerfile.engine-dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ENV PRODUCT ${PRODUCT}
ENV DEFAULT_PRODUCT_LICENSE ${DEFAULT_PRODUCT_LICENSE}
# TODO The way we set the version could easily be simplified not to depend on hack/...
RUN bash ./hack/make/.go-autogen
RUN go build -o /sbin/dockerd \
RUN go build -o /dockerd \
-tags 'autogen apparmor seccomp selinux journald' \
-i \
-buildmode=pie \
Expand All @@ -60,7 +60,7 @@ WORKDIR /go/src/github.com/docker/libnetwork
RUN . /binaries-commits && \
git checkout -q "$LIBNETWORK_COMMIT" && \
go build -buildmode=pie -ldflags="-w" \
-o /sbin/docker-proxy \
-o /docker-proxy \
github.com/docker/libnetwork/cmd/proxy

# docker-init - TODO move this out, last time we bumped was 2016!
Expand All @@ -70,11 +70,11 @@ WORKDIR /tini
RUN . /binaries-commits && \
git checkout -q "$TINI_COMMIT" && \
cmake . && make tini-static && \
cp tini-static /sbin/docker-init
cp tini-static /docker-init

# Final docker image
FROM scratch
COPY --from=dockerd-builder /sbin/dockerd /sbin/
COPY --from=proxy-builder /sbin/docker-proxy /sbin/
COPY --from=init-builder /sbin/docker-init /sbin/
COPY --from=dockerd-builder /dockerd /sbin/
COPY --from=proxy-builder /docker-proxy /sbin/
COPY --from=init-builder /docker-init /sbin/
ENTRYPOINT ["/sbin/dockerd"]
Loading

0 comments on commit 2299607

Please sign in to comment.