Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RPM packaging for 18.09.x #131

Merged
merged 11 commits into from
Aug 16, 2018
Prev Previous commit
Next Next commit
Add containerd-shim-process installation
Also split off containerd.mk into it's own thing since most of this
stuff will be re-used with debian packaging anyways.

Signed-off-by: Eli Uriegas <[email protected]>
  • Loading branch information
seemethere committed Aug 14, 2018
commit 5513629a1b4868d82a41249eac634edbff51e315
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ build
debbuild
rpmbuild
tmp
artifacts
17 changes: 17 additions & 0 deletions containerd.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Common things for containerd functionality

CONTAINERD_PROXY_COMMIT=3337fb47f10892318361b58c8483f19b1ffa8203
CONTAINERD_SHIM_PROCESS_IMAGE=docker.io/docker/containerd-shim-process:a4d1531

# If the docker-containerd.sock is available use that, else use the default containerd.sock
ifeq (,$(wildcard /var/run/docker/containerd/docker-containerd.sock))
CONTAINERD_SOCK:=/var/run/docker/containerd/docker-containerd.sock
else
CONTAINERD_SOCK:=/var/run/containerd/containerd.sock
endif
CTR=docker run \
--rm -i \
-v $(CONTAINERD_SOCK):/ours/containerd.sock \
-v $(CURDIR)/artifacts:/artifacts \
docker:18.06.0-ce \
docker-containerd-ctr -a /ours/containerd.sock
17 changes: 13 additions & 4 deletions rpm/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include ../containerd.mk

ARCH=$(shell uname -m)
ENGINE_DIR:=$(CURDIR)/../../engine
CLI_DIR:=$(CURDIR)/../../cli
Expand All @@ -17,11 +19,9 @@ RPMBUILD_FLAGS=-ba\
--define '_origversion $(word 4, $(GEN_RPM_VER))' \
SPECS/docker-ce.spec SPECS/docker-ce-cli.spec

SOURCE_TGZS=containerd-proxy.tgz cli.tgz
SOURCE_TGZS=containerd-proxy.tgz cli.tgz containerd-shim-process.tar
SOURCES=$(addprefix rpmbuild/SOURCES/, $(SOURCE_TGZS))

CONTAINERD_PROXY_COMMIT=3337fb47f10892318361b58c8483f19b1ffa8203

.PHONY: help
help: ## show make targets
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
Expand All @@ -44,20 +44,23 @@ centos: centos-7 ## build all centos rpm packages
.PHONY: fedora-28
fedora-28: ## build fedora-28 rpm packages
fedora-28: $(SOURCES)
$(CHOWN) -R root:root rpmbuild
docker build --build-arg GO_VERSION=$(GO_VERSION) -t rpmbuild-$@/$(ARCH) -f $@/Dockerfile.$(ARCH) .
$(RPMBUILD) rpmbuild-$@/$(ARCH) $(RPMBUILD_FLAGS)
$(CHOWN) -R $(shell id -u):$(shell id -g) rpmbuild

.PHONY: fedora-27
fedora-27: ## build fedora-27 rpm packages
fedora-27: $(SOURCES)
$(CHOWN) -R root:root rpmbuild
docker build --build-arg GO_VERSION=$(GO_VERSION) -t rpmbuild-$@/$(ARCH) -f $@/Dockerfile.$(ARCH) .
$(RPMBUILD) rpmbuild-$@/$(ARCH) $(RPMBUILD_FLAGS)
$(CHOWN) -R $(shell id -u):$(shell id -g) rpmbuild

.PHONY: centos-7
centos-7: ## build centos-7 rpm packages
centos-7: $(SOURCES)
$(CHOWN) -R root:root rpmbuild
docker build --build-arg GO_VERSION=$(GO_VERSION) -t rpmbuild-$@/$(ARCH) -f $@/Dockerfile.$(ARCH) .
$(RPMBUILD) rpmbuild-$@/$(ARCH) $(RPMBUILD_FLAGS)
$(CHOWN) -R $(shell id -u):$(shell id -g) rpmbuild
Expand All @@ -79,4 +82,10 @@ rpmbuild/SOURCES/containerd-proxy.tgz:
$(CHOWN) -R $(shell id -u):$(shell id -g) rpmbuild
tar -zcf $@ -C tmp/ containerd-proxy
rm -rf tmp/
$(CHOWN) -R root:root rpmbuild/SOURCES

rpmbuild/SOURCES/containerd-shim-process.tar:
$(CTR) content fetch $(CONTAINERD_SHIM_PROCESS_IMAGE)
$(CTR) image export artifacts/containerd-shim-process.tar $(CONTAINERD_SHIM_PROCESS_IMAGE)
mkdir -p $(@D)
cp artifacts/containerd-shim-process.tar $@
$(CHOWN) -R $(shell id -u):$(shell id -g) rpmbuild
7 changes: 7 additions & 0 deletions rpm/SPECS/docker-ce.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Version: %{_version}
Release: %{_release}%{?dist}
Epoch: %{getenv:EPOCH}
Source0: containerd-proxy.tgz
Source1: containerd-shim-process.tar
Summary: The open-source application container engine
Group: Tools/Docker
License: ASL 2.0
Expand All @@ -13,6 +14,8 @@ Vendor: Docker
Packager: Docker <[email protected]>

Requires: docker-ce-cli
# Should be required as well by docker-ce-cli but let's just be thorough
Requires: containerd.io

# conflicting packages
Conflicts: docker
Expand Down Expand Up @@ -40,16 +43,20 @@ depending on a particular stack or provider.
%setup -q -c -n src

%build
# dockerd proxy compilation
mkdir -p /go/src/github.com/crosbymichael/
ls %{_topdir}/BUILD/src
ln -s %{_topdir}/BUILD/src/containerd-proxy /go/src/github.com/crosbymichael/containerd-proxy
go build -v -o /build/dockerd github.com/crosbymichael/containerd-proxy

%install
install -D -m 0755 /build/dockerd $RPM_BUILD_ROOT/%{_bindir}/dockerd
# TODO: Use containerd-offline-installer to actually install this as ExecStartPre systemd step
install -D -m 0644 %{_topdir}/SOURCES/containerd-shim-process.tar $RPM_BUILD_ROOT/%{_sharedstatedir}/containerd/containerd-shim-process.tar

%files
/%{_bindir}/dockerd
/%{_sharedstatedir}/containerd/containerd-shim-process.tar

%post
if ! getent group docker > /dev/null; then
Expand Down