Add debian package for docker-distribution

- created required debian structure
- successfully built the package
- applied stx config changes and updated
paths from /etc/docker to /etc/docker-distribution
through patches

Story: 2009221
Task: 43631
Signed-off-by: Daniel Safta <daniel.safta@windriver.com>
Change-Id: I5af677c90342bae7c10101bf100e1db79c716670
This commit is contained in:
Daniel Safta 2021-11-03 13:11:40 +02:00
parent 36673774ee
commit b9d28e3c56
6 changed files with 247 additions and 0 deletions

View File

@ -0,0 +1,68 @@
From 922d937e24a4a0cd9d826579eeb9afed4f7c234c Mon Sep 17 00:00:00 2001
From: Daniel Safta <daniel.safta@windriver.com>
Date: Wed, 3 Nov 2021 09:48:45 +0000
Subject: [PATCH] debian-patches
---
debian/docker-registry.init | 2 +-
debian/docker-registry.install | 2 +-
debian/docker-registry.postinst | 2 +-
debian/docker-registry.service | 7 ++++++-
4 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/debian/docker-registry.init b/debian/docker-registry.init
index c225130..c03a67a 100644
--- a/debian/docker-registry.init
+++ b/debian/docker-registry.init
@@ -13,7 +13,7 @@ set -e
BASE=docker-registry
BINARY=/usr/bin/$BASE
-CONFIG=/etc/docker/registry/config.yml
+CONFIG=/etc/docker-distribution/registry/config.yml
EXECUSER=docker-registry
PIDFILE=/var/run/$BASE.pid
LOGFILE=/var/log/$BASE.log
diff --git a/debian/docker-registry.install b/debian/docker-registry.install
index ea1de25..6ed37e3 100755
--- a/debian/docker-registry.install
+++ b/debian/docker-registry.install
@@ -1,3 +1,3 @@
#!/usr/bin/dh-exec
usr/bin/registry => usr/bin/docker-registry
-cmd/registry/config-example.yml => etc/docker/registry/config.yml
+cmd/registry/config-example.yml => etc/docker-distribution/registry/config.yml
diff --git a/debian/docker-registry.postinst b/debian/docker-registry.postinst
index 96ded3c..d179197 100755
--- a/debian/docker-registry.postinst
+++ b/debian/docker-registry.postinst
@@ -15,7 +15,7 @@ if [ "$1" = 'configure' ]; then
# On a fresh install, $2 = '' and dpkg treat that as a
# lower version, so the permissions get fixed too.
if dpkg --compare-versions "$2" le '2.4.1~ds1-1'; then
- chmod 0755 /etc/docker
+ chmod 0755 /etc/docker-distribution
fi
# ensure home directory ownership (logic borrowed from postgresql-common)
diff --git a/debian/docker-registry.service b/debian/docker-registry.service
index 066e38a..a2feaa6 100644
--- a/debian/docker-registry.service
+++ b/debian/docker-registry.service
@@ -4,7 +4,12 @@ After=network.target
[Service]
User=docker-registry
-ExecStart=/usr/bin/docker-registry serve /etc/docker/registry/config.yml
+Type=simple
+Environment=REGISTRY_STORAGE_DELETE_ENABLED=true
+ExecStart=/usr/bin/docker-registry serve /etc/docker-distribution/registry/config.yml
+Restart=on-failure
+ExecStartPost=/bin/bash -c 'echo $MAINPID > /var/run/docker-distribution.pid'
+ExecStopPost=/bin/rm -f /var/run/docker-distribution.pid
[Install]
WantedBy=multi-user.target
--
2.30.2

View File

@ -0,0 +1 @@
0001-update-paths-and-service.patch

View File

@ -0,0 +1,20 @@
#!/bin/bash
set -x
#link to the debian folder structure
SUBMODULE_SRC1=https://salsa.debian.org/go-team/packages/golang-github-docker-distribution/-/archive/debian/2.7.1+ds2-7/golang-github-docker-distribution-debian-2.7.1+ds2-7.tar.bz2
#link to source files
SUBMODULE_SRC2=https://github.com/docker/distribution/archive/v2.7.1.tar.gz
PKG_BUILD_NAME=$1
mkdir ${PKG_BUILD_NAME}
pushd ${PKG_BUILD_NAME}
PKG=golang-github-docker-distribution-debian-2.7.1+ds2-7.tar.bz2
wget $SUBMODULE_SRC1 -O $PKG
tar --bzip2 -xvf $PKG --strip-components 1
PKG=v2.7.1.tar.gz
wget $SUBMODULE_SRC2 -O $PKG
tar -xvzf $PKG --strip-components 1

View File

@ -0,0 +1,7 @@
---
debname: docker-registry
debver: 2.7.1+ds2-7
dl_hook: dl_hook
revision:
dist: $STX_DIST
PKG_GITREVCOUNT: true

View File

@ -0,0 +1,150 @@
From 8d41cb5a84e9d7a51a02e3e33289008bdf2a5491 Mon Sep 17 00:00:00 2001
From: Daniel Safta <daniel.safta@windriver.com>
Date: Wed, 3 Nov 2021 09:50:59 +0000
Subject: [PATCH] code-patches
---
Dockerfile | 4 ++--
cmd/registry/config-example.yml | 2 +-
contrib/docker-integration/docker-compose.yml | 22 +++++++++----------
.../registry-config-notls.yml | 2 +-
.../tokenserver-oauth/registry-config.yml | 6 ++---
.../tokenserver/registry-config.yml | 6 ++---
6 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index 9537817..5c92094 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -15,9 +15,9 @@ COPY . $DISTRIBUTION_DIR
RUN CGO_ENABLED=0 make PREFIX=/go clean binaries && file ./bin/registry | grep "statically linked"
FROM alpine
-COPY cmd/registry/config-dev.yml /etc/docker/registry/config.yml
+COPY cmd/registry/config-dev.yml /etc/docker-distribution/registry/config.yml
COPY --from=build /go/src/github.com/docker/distribution/bin/registry /bin/registry
VOLUME ["/var/lib/registry"]
EXPOSE 5000
ENTRYPOINT ["registry"]
-CMD ["serve", "/etc/docker/registry/config.yml"]
+CMD ["serve", "/etc/docker-distribution/registry/config.yml"]
diff --git a/cmd/registry/config-example.yml b/cmd/registry/config-example.yml
index d2aecbb..30c9f62 100644
--- a/cmd/registry/config-example.yml
+++ b/cmd/registry/config-example.yml
@@ -16,7 +16,7 @@ http:
auth:
htpasswd:
realm: basic-realm
- path: /etc/docker/registry
+ path: /etc/docker-distribution/registry
health:
storagedriver:
enabled: true
diff --git a/contrib/docker-integration/docker-compose.yml b/contrib/docker-integration/docker-compose.yml
index 374197a..74f203f 100644
--- a/contrib/docker-integration/docker-compose.yml
+++ b/contrib/docker-integration/docker-compose.yml
@@ -37,10 +37,10 @@ registryv2token:
ports:
- "5000"
volumes:
- - ./tokenserver/registry-config.yml:/etc/docker/registry/config.yml
- - ./tokenserver/certs/localregistry.cert:/etc/docker/registry/localregistry.cert
- - ./tokenserver/certs/localregistry.key:/etc/docker/registry/localregistry.key
- - ./tokenserver/certs/signing.cert:/etc/docker/registry/tokenbundle.pem
+ - ./tokenserver/registry-config.yml:/etc/docker-distribution/registry/config.yml
+ - ./tokenserver/certs/localregistry.cert:/etc/docker-distribution/registry/localregistry.cert
+ - ./tokenserver/certs/localregistry.key:/etc/docker-distribution/registry/localregistry.key
+ - ./tokenserver/certs/signing.cert:/etc/docker-distribution/registry/tokenbundle.pem
tokenserver:
build: "tokenserver"
command: "--debug -addr 0.0.0.0:5556 -issuer registry-test -passwd .htpasswd -tlscert tls.cert -tlskey tls.key -key sign.key -realm http://auth.localregistry:5556"
@@ -51,17 +51,17 @@ registryv2tokenoauth:
ports:
- "5000"
volumes:
- - ./tokenserver-oauth/registry-config.yml:/etc/docker/registry/config.yml
- - ./tokenserver-oauth/certs/localregistry.cert:/etc/docker/registry/localregistry.cert
- - ./tokenserver-oauth/certs/localregistry.key:/etc/docker/registry/localregistry.key
- - ./tokenserver-oauth/certs/signing.cert:/etc/docker/registry/tokenbundle.pem
+ - ./tokenserver-oauth/registry-config.yml:/etc/docker-distribution/registry/config.yml
+ - ./tokenserver-oauth/certs/localregistry.cert:/etc/docker-distribution/registry/localregistry.cert
+ - ./tokenserver-oauth/certs/localregistry.key:/etc/docker-distribution/registry/localregistry.key
+ - ./tokenserver-oauth/certs/signing.cert:/etc/docker-distribution/registry/tokenbundle.pem
registryv2tokenoauthnotls:
image: golem-distribution:latest
ports:
- "5000"
volumes:
- - ./tokenserver-oauth/registry-config-notls.yml:/etc/docker/registry/config.yml
- - ./tokenserver-oauth/certs/signing.cert:/etc/docker/registry/tokenbundle.pem
+ - ./tokenserver-oauth/registry-config-notls.yml:/etc/docker-distribution/registry/config.yml
+ - ./tokenserver-oauth/certs/signing.cert:/etc/docker-distribution/registry/tokenbundle.pem
tokenserveroauth:
build: "tokenserver-oauth"
command: "--debug -addr 0.0.0.0:5559 -issuer registry-test -passwd .htpasswd -tlscert tls.cert -tlskey tls.key -key sign.key -realm http://auth.localregistry:5559 -enforce-class"
@@ -84,7 +84,7 @@ docker:
environment:
DOCKER_GRAPHDRIVER:
volumes:
- - /etc/generated_certs.d:/etc/docker/certs.d
+ - /etc/generated_certs.d:/etc/docker-distribution/certs.d
- /var/lib/docker
links:
- nginx:localregistry
diff --git a/contrib/docker-integration/tokenserver-oauth/registry-config-notls.yml b/contrib/docker-integration/tokenserver-oauth/registry-config-notls.yml
index a700d08..bbde741 100644
--- a/contrib/docker-integration/tokenserver-oauth/registry-config-notls.yml
+++ b/contrib/docker-integration/tokenserver-oauth/registry-config-notls.yml
@@ -15,4 +15,4 @@ auth:
realm: "https://auth.localregistry:5559/token/"
issuer: "registry-test"
service: "registry-test"
- rootcertbundle: "/etc/docker/registry/tokenbundle.pem"
+ rootcertbundle: "/etc/docker-distribution/registry/tokenbundle.pem"
diff --git a/contrib/docker-integration/tokenserver-oauth/registry-config.yml b/contrib/docker-integration/tokenserver-oauth/registry-config.yml
index 226798b..253769f 100644
--- a/contrib/docker-integration/tokenserver-oauth/registry-config.yml
+++ b/contrib/docker-integration/tokenserver-oauth/registry-config.yml
@@ -8,8 +8,8 @@ storage:
http:
addr: 0.0.0.0:5000
tls:
- certificate: "/etc/docker/registry/localregistry.cert"
- key: "/etc/docker/registry/localregistry.key"
+ certificate: "/etc/docker-distribution/registry/localregistry.cert"
+ key: "/etc/docker-distribution/registry/localregistry.key"
compatibility:
schema1:
enabled: true
@@ -18,4 +18,4 @@ auth:
realm: "https://auth.localregistry:5559/token/"
issuer: "registry-test"
service: "registry-test"
- rootcertbundle: "/etc/docker/registry/tokenbundle.pem"
+ rootcertbundle: "/etc/docker-distribution/registry/tokenbundle.pem"
diff --git a/contrib/docker-integration/tokenserver/registry-config.yml b/contrib/docker-integration/tokenserver/registry-config.yml
index b9efdd3..11be98e 100644
--- a/contrib/docker-integration/tokenserver/registry-config.yml
+++ b/contrib/docker-integration/tokenserver/registry-config.yml
@@ -8,8 +8,8 @@ storage:
http:
addr: 0.0.0.0:5000
tls:
- certificate: "/etc/docker/registry/localregistry.cert"
- key: "/etc/docker/registry/localregistry.key"
+ certificate: "/etc/docker-distribution/registry/localregistry.cert"
+ key: "/etc/docker-distribution/registry/localregistry.key"
compatibility:
schema1:
enabled: true
@@ -18,4 +18,4 @@ auth:
realm: "https://auth.localregistry:5556/token/"
issuer: "registry-test"
service: "registry-test"
- rootcertbundle: "/etc/docker/registry/tokenbundle.pem"
+ rootcertbundle: "/etc/docker-distribution/registry/tokenbundle.pem"
--
2.30.2

View File

@ -0,0 +1 @@
0001-update-paths.patch