Skip to content

Commit

Permalink
Merge pull request #223 from seemethere/f
Browse files Browse the repository at this point in the history
Use image artifacts as daemon and dependencies
  • Loading branch information
seemethere authored Sep 21, 2018
2 parents 10ec63c + 944fa71 commit 06ff8d1
Show file tree
Hide file tree
Showing 22 changed files with 207 additions and 144 deletions.
41 changes: 11 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 distribution_based_engine.json
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,16 @@ 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/distribution_based_engine.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 $@
docker inspect "$(shell cat $<)" \
--format '{{index .Config.Labels "com.docker.distribution_based_engine" }}' > $@

sources/engine-image:
mkdir -p $(@D)
$(MAKE) -C ../image image-linux
cp ../image/image-linux $@
1 change: 1 addition & 0 deletions deb/common/control
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Build-Depends: bash-completion,
dh-apparmor,
dh-systemd,
libltdl-dev,
libseccomp2,
make,
gcc
Standards-Version: 3.9.6
Expand Down
24 changes: 24 additions & 0 deletions deb/common/docker-ce.postinst
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@
#!/bin/sh
set -e

update_dockerd() {
dbefile=/var/lib/docker/distribution_based_engine.json
URL=https://docs.docker.com/releasenote
if [ -f "${dbefile}" ] && sed -e 's/.*"platform"[ \t]*:[ \t]*"\([^"]*\)".*/\1/g' "${dbefile}"| grep -v -i community > /dev/null; then
echo
echo
echo
echo "Warning: Your engine has been activated to Docker Engine - Enterprise but you are still using Community packages"
echo "You can use the 'docker engine update' command to update your system, or switch to using the Enterprise packages."
echo "See $URL for more details."
echo
echo
echo
else
rm -f /usr/bin/dockerd
update-alternatives --install /usr/bin/dockerd dockerd /usr/bin/dockerd-ce 1 --slave \
${dbefile} distribution_based_engine.json /var/lib/docker/distribution_based_engine-ce.json
fi
}

case "$1" in
configure)
if [ -z "$2" ]; then
if ! getent group docker > /dev/null; then
groupadd --system docker
fi
fi
update_dockerd
;;
update)
update_dockerd
;;
abort-*)
# How'd we get here??
Expand Down
5 changes: 5 additions & 0 deletions deb/common/docker-ce.prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
set -e

update-alternatives --remove dockerd /usr/bin/dockerd-ce

15 changes: 6 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,19 @@ 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-ce
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
install -D -m 0644 /sources/distribution_based_engine.json debian/docker-ce/var/lib/docker/distribution_based_engine-ce.json

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 /bin/dockerd /source/
COPY --from=engine /bin/docker-proxy /source/
COPY --from=engine /bin/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 /bin/dockerd /source/
COPY --from=engine /bin/docker-proxy /source/
COPY --from=engine /bin/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 /bin/dockerd /source/
COPY --from=engine /bin/docker-proxy /source/
COPY --from=engine /bin/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 /bin/dockerd /source/
COPY --from=engine /bin/docker-proxy /source/
COPY --from=engine /bin/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 /bin/dockerd /source/
COPY --from=engine /bin/docker-proxy /source/
COPY --from=engine /bin/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 /bin/dockerd /source/
COPY --from=engine /bin/docker-proxy /source/
COPY --from=engine /bin/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 /bin/dockerd /source/
COPY --from=engine /bin/docker-proxy /source/
COPY --from=engine /bin/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 /bin/dockerd /source/
COPY --from=engine /bin/docker-proxy /source/
COPY --from=engine /bin/docker-init /source/

WORKDIR /root/build-deb
COPY build-deb /root/build-deb/build-deb
Expand Down
Loading

0 comments on commit 06ff8d1

Please sign in to comment.