From 832eaa1f679c8566f2a36858c675527bd52db532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Sat, 28 Oct 2017 02:14:44 +0200 Subject: [PATCH 1/4] Use ordinary shell variables instead of ENV for REGISTRY_COMMIT* They are only used in the immediately following shell snippet, no need to pollute the container environment with them, nor to add two extra layers. --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0ddf94f9..5198ae2d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,9 +13,9 @@ RUN dnf -y update && dnf install -y make git golang golang-github-cpuguy83-go-md # only supports schema1 manifests. The second is a newer version that supports # both. This allows integration-cli tests to cover push/pull with both schema1 # and schema2 manifests. -ENV REGISTRY_COMMIT_SCHEMA1 ec87e9b6971d831f0eff752ddb54fb64693e51cd -ENV REGISTRY_COMMIT 47a064d4195a9b56133891bbb13620c3ac83a827 RUN set -x \ + && REGISTRY_COMMIT_SCHEMA1=ec87e9b6971d831f0eff752ddb54fb64693e51cd \ + && REGISTRY_COMMIT=47a064d4195a9b56133891bbb13620c3ac83a827 \ && export GOPATH="$(mktemp -d)" \ && git clone https://github.com/docker/distribution.git "$GOPATH/src/github.com/docker/distribution" \ && (cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT") \ From 3f10c1726d84e63dd87faaac61d1c83c29fb87e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Sat, 28 Oct 2017 02:16:25 +0200 Subject: [PATCH 2/4] Do not use a separate yum command to install OpenShift dependencies We don't really need to pay the depsolving overhead twice. --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5198ae2d..0f6ce245 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,9 @@ RUN dnf -y update && dnf install -y make git golang golang-github-cpuguy83-go-md # gpgme bindings deps libassuan-devel gpgme-devel \ ostree-devel \ - gnupg + gnupg \ + # OpenShift deps + which tar wget hostname util-linux bsdtar socat ethtool device-mapper iptables tree findutils nmap-ncat e2fsprogs xfsprogs lsof docker iproute # Install two versions of the registry. The first is an older version that # only supports schema1 manifests. The second is a newer version that supports @@ -27,7 +29,6 @@ RUN set -x \ && rm -rf "$GOPATH" RUN set -x \ - && yum install -y which git tar wget hostname util-linux bsdtar socat ethtool device-mapper iptables tree findutils nmap-ncat e2fsprogs xfsprogs lsof docker iproute \ && export GOPATH=$(mktemp -d) \ && git clone --depth 1 -b v1.5.0-alpha.3 git://github.com/openshift/origin "$GOPATH/src/github.com/openshift/origin" \ && (cd "$GOPATH/src/github.com/openshift/origin" && make clean build && make all WHAT=cmd/dockerregistry) \ From a7e8a9b4d4a91cd5d5a4fc971e4b35fa7db5865f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Sat, 28 Oct 2017 02:17:15 +0200 Subject: [PATCH 3/4] Run (dnf clean all) after finishing the installation ... to drop all caches which will never be needed again. --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0f6ce245..aba86f60 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,8 @@ RUN dnf -y update && dnf install -y make git golang golang-github-cpuguy83-go-md ostree-devel \ gnupg \ # OpenShift deps - which tar wget hostname util-linux bsdtar socat ethtool device-mapper iptables tree findutils nmap-ncat e2fsprogs xfsprogs lsof docker iproute + which tar wget hostname util-linux bsdtar socat ethtool device-mapper iptables tree findutils nmap-ncat e2fsprogs xfsprogs lsof docker iproute \ + && dnf clean all # Install two versions of the registry. The first is an older version that # only supports schema1 manifests. The second is a newer version that supports From 83ca46607152593cada7f0d1b8014d60f53392f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Sat, 28 Oct 2017 02:17:49 +0200 Subject: [PATCH 4/4] Remove the openshift/origin checkout from /tmp after building it --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index aba86f60..ce9dbcc6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,6 +35,7 @@ RUN set -x \ && (cd "$GOPATH/src/github.com/openshift/origin" && make clean build && make all WHAT=cmd/dockerregistry) \ && cp -a "$GOPATH/src/github.com/openshift/origin/_output/local/bin/linux"/*/* /usr/local/bin \ && cp "$GOPATH/src/github.com/openshift/origin/images/dockerregistry/config.yml" /atomic-registry-config.yml \ + && rm -rf "$GOPATH" \ && mkdir /registry ENV GOPATH /usr/share/gocode:/go