Skip to content

Commit

Permalink
Add RPM package building for docker-ce-cli
Browse files Browse the repository at this point in the history
Splits out the docker-ce package and docker-ce-cli package into their
own things.

Still TODO: need to have a cleanup on the dependencies for the
Dockerfiles

Signed-off-by: Eli Uriegas <[email protected]>
  • Loading branch information
seemethere committed Aug 9, 2018
1 parent 0b37662 commit 8e5ccb0
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 658 deletions.
29 changes: 9 additions & 20 deletions rpm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@ CLI_DIR:=$(CURDIR)/../../cli
GITCOMMIT=$(shell cd $(ENGINE_DIR) && git rev-parse --short HEAD)
VERSION?=0.0.0-dev
GO_VERSION:=1.10.3
GEN_RPM_VER=$(shell ./gen-rpm-ver $(ENGINE_DIR) $(VERSION))
GEN_RPM_VER=$(shell ./gen-rpm-ver $(CLI_DIR) $(VERSION))
EPOCH?=2
CHOWN=docker run --rm -i -v $(CURDIR):/v -w /v alpine chown
RPMBUILD=docker run --privileged --rm -i\
-e EPOCH="$(EPOCH)" \
-v $(CURDIR)/rpmbuild/SOURCES:/root/rpmbuild/SOURCES \
-v $(CURDIR)/rpmbuild/BUILD:/root/rpmbuild/BUILD \
-v $(CURDIR)/rpmbuild/BUILDROOT:/root/rpmbuild/BUILDROOT \
-v $(CURDIR)/rpmbuild/RPMS:/root/rpmbuild/RPMS \
-v $(CURDIR)/rpmbuild/SRPMS:/root/rpmbuild/SRPMS \
-v $(CURDIR)/systemd:/systemd
-v $(CURDIR)/rpmbuild/SRPMS:/root/rpmbuild/SRPMS
RPMBUILD_FLAGS=-ba\
--define '_gitcommit $(word 3,$(GEN_RPM_VER))' \
--define '_release $(word 2,$(GEN_RPM_VER))' \
--define '_version $(word 1,$(GEN_RPM_VER))' \
--define '_origversion $(word 4, $(GEN_RPM_VER))' \
SPECS/docker-ce.spec
SPECS/docker-ce-cli.spec SPECS/docker-ce.spec

.PHONY: help
help: ## show make targets
Expand All @@ -45,20 +42,20 @@ engine-$(ARCH).tar:
docker save -o $@ $$(cat ../image/image-linux)

.PHONY: fedora-28
fedora-28: engine-$(ARCH).tar rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz ## build fedora-28 rpm packages
docker build --build-arg GO_VERSION=$(GO_VERSION) -t rpmbuild-$@/$(ARCH) -f $@/Dockerfile.$(ARCH) $@
fedora-28: engine-$(ARCH).tar rpmbuild/SOURCES/cli.tgz ## build fedora-28 rpm packages
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:engine-$(ARCH).tar rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz ## build fedora-27 rpm packages
docker build --build-arg GO_VERSION=$(GO_VERSION) -t rpmbuild-$@/$(ARCH) -f $@/Dockerfile.$(ARCH) $@
fedora-27: engine-$(ARCH).tar rpmbuild/SOURCES/cli.tgz ## build fedora-27 rpm packages
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:engine-$(ARCH).tar rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz ## build centos-7 rpm packages
docker build --build-arg GO_VERSION=$(GO_VERSION) -t rpmbuild-$@/$(ARCH) -f $@/Dockerfile.$(ARCH) $@
centos-7: engine-$(ARCH).tar rpmbuild/SOURCES/cli.tgz ## build centos-7 rpm packages
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 @@ -69,11 +66,3 @@ rpmbuild/SOURCES/cli.tgz:
-v $(CURDIR)/rpmbuild/SOURCES:/v \
alpine \
tar -C / -c -z -f /v/cli.tgz --exclude .git cli

rpmbuild/SOURCES/engine.tgz:
mkdir -p rpmbuild/SOURCES
docker run --rm -i -w /v \
-v $(ENGINE_DIR):/engine \
-v $(CURDIR)/rpmbuild/SOURCES:/v \
alpine \
tar -C / -c -z -f /v/engine.tgz --exclude .git engine
100 changes: 100 additions & 0 deletions rpm/SPECS/docker-ce-cli.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
%global debug_package %{nil}

Name: docker-ce-cli
Version: %{_version}
Release: %{_release}%{?dist}
Epoch: %{getenv:EPOCH}
Summary: The open-source application container engine
Group: Tools/Docker
License: ASL 2.0
Source0: cli.tgz
URL: https://www.docker.com
Vendor: Docker
Packager: Docker <[email protected]>

# required packages on install
Requires: /bin/sh
Requires: containerd

# conflicting packages
Conflicts: docker
Conflicts: docker-io
Conflicts: docker-engine-cs
Conflicts: docker-ee
Conflicts: docker-ee-cli

# Obsolete packages
Obsoletes: docker-ce-selinux
Obsoletes: docker-engine-selinux
Obsoletes: docker-engine

%description
Docker is an open source project to build, ship and run any application as a
lightweight container.

Docker containers are both hardware-agnostic and platform-agnostic. This means
they can run anywhere, from your laptop to the largest EC2 compute instance and
everything in between - and they don't require you to use a particular
language, framework or packaging system. That makes them great building blocks
for deploying and scaling web apps, databases, and backend services without
depending on a particular stack or provider.

%prep
%setup -q -c -n src

%build
mkdir -p /go/src/github.com/docker
rm -f /go/src/github.com/docker/cli
ln -s /root/rpmbuild/BUILD/src/cli /go/src/github.com/docker/cli
pushd /go/src/github.com/docker/cli
DISABLE_WARN_OUTSIDE_CONTAINER=1 make VERSION=%{_origversion} GITCOMMIT=%{_gitcommit} dynbinary manpages # cli
popd

# %check
# cli/build/docker -v

%install
# install binary
install -d $RPM_BUILD_ROOT/%{_bindir}
install -p -m 755 cli/build/docker $RPM_BUILD_ROOT/%{_bindir}/docker

# add bash, zsh, and fish completions
install -d $RPM_BUILD_ROOT/usr/share/bash-completion/completions
install -d $RPM_BUILD_ROOT/usr/share/zsh/vendor-completions
install -d $RPM_BUILD_ROOT/usr/share/fish/vendor_completions.d
install -p -m 644 cli/contrib/completion/bash/docker $RPM_BUILD_ROOT/usr/share/bash-completion/completions/docker
install -p -m 644 cli/contrib/completion/zsh/_docker $RPM_BUILD_ROOT/usr/share/zsh/vendor-completions/_docker
install -p -m 644 cli/contrib/completion/fish/docker.fish $RPM_BUILD_ROOT/usr/share/fish/vendor_completions.d/docker.fish

# install manpages
install -d %{buildroot}%{_mandir}/man1
install -p -m 644 cli/man/man1/*.1 $RPM_BUILD_ROOT/%{_mandir}/man1
install -d %{buildroot}%{_mandir}/man5
install -p -m 644 cli/man/man5/*.5 $RPM_BUILD_ROOT/%{_mandir}/man5
install -d %{buildroot}%{_mandir}/man8
install -p -m 644 cli/man/man8/*.8 $RPM_BUILD_ROOT/%{_mandir}/man8

mkdir -p build-docs
for cli_file in LICENSE MAINTAINERS NOTICE README.md; do
cp "cli/$cli_file" "build-docs/$cli_file"
done

# list files owned by the package here
%files
%doc build-docs/LICENSE build-docs/MAINTAINERS build-docs/NOTICE build-docs/README.md
/%{_bindir}/docker
/usr/share/bash-completion/completions/docker
/usr/share/zsh/vendor-completions/_docker
/usr/share/fish/vendor_completions.d/docker.fish
%doc
/%{_mandir}/man1/*
/%{_mandir}/man5/*
/%{_mandir}/man8/*


%post
if ! getent group docker > /dev/null; then
groupadd --system docker
fi

%changelog
51 changes: 51 additions & 0 deletions rpm/SPECS/docker-ce.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
%global debug_package %{nil}

Name: docker-ce
Version: %{_version}
Release: %{_release}%{?dist}
Epoch: %{getenv:EPOCH}
Summary: The open-source application container engine
Group: Tools/Docker
License: ASL 2.0
URL: https://www.docker.com
Vendor: Docker
Packager: Docker <[email protected]>

Requires: docker-ce-cli

# conflicting packages
Conflicts: docker
Conflicts: docker-io
Conflicts: docker-engine-cs
Conflicts: docker-ee

# Obsolete packages
Obsoletes: docker-ce-selinux
Obsoletes: docker-engine-selinux
Obsoletes: docker-engine

%description
Docker is an open source project to build, ship and run any application as a
lightweight container.

Docker containers are both hardware-agnostic and platform-agnostic. This means
they can run anywhere, from your laptop to the largest EC2 compute instance and
everything in between - and they don't require you to use a particular
language, framework or packaging system. That makes them great building blocks
for deploying and scaling web apps, databases, and backend services without
depending on a particular stack or provider.

%install

%files

%post
if ! getent group docker > /dev/null; then
groupadd --system docker
fi
# TODO Needs upgrade vs. install logic handling here
if ctr --namespace docker container info dockerd > /dev/null 2>&1 ; then
docker engine init
fi

%changelog
2 changes: 1 addition & 1 deletion rpm/centos-7/Dockerfile.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ ENV AUTO_GOPATH 1
ENV DOCKER_BUILDTAGS pkcs11 seccomp selinux
ENV RUNC_BUILDTAGS seccomp selinux
RUN mkdir -p /go/src/github.com/docker && mkdir -p /go/src/github.com/opencontainers
COPY docker-ce.spec /root/rpmbuild/SPECS/docker-ce.spec
COPY SPECS /root/rpmbuild/SPECS
WORKDIR /root/rpmbuild
ENTRYPOINT ["/bin/rpmbuild"]
2 changes: 1 addition & 1 deletion rpm/centos-7/Dockerfile.x86_64
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ ENV AUTO_GOPATH 1
ENV DOCKER_BUILDTAGS pkcs11 seccomp selinux
ENV RUNC_BUILDTAGS seccomp selinux
RUN mkdir -p /go/src/github.com/docker && mkdir -p /go/src/github.com/opencontainers
COPY docker-ce.spec /root/rpmbuild/SPECS/docker-ce.spec
COPY SPECS /root/rpmbuild/SPECS
WORKDIR /root/rpmbuild
ENTRYPOINT ["/bin/rpmbuild"]
Loading

0 comments on commit 8e5ccb0

Please sign in to comment.