diff options
Diffstat (limited to 'app-containers/reg')
-rw-r--r-- | app-containers/reg/Manifest | 7 | ||||
-rw-r--r-- | app-containers/reg/files/reg-0.16.0-config.patch | 254 | ||||
-rw-r--r-- | app-containers/reg/files/reg.confd | 2 | ||||
-rw-r--r-- | app-containers/reg/files/reg.initd | 19 | ||||
-rw-r--r-- | app-containers/reg/metadata.xml | 11 | ||||
-rw-r--r-- | app-containers/reg/reg-0.16.1.ebuild | 54 |
6 files changed, 347 insertions, 0 deletions
diff --git a/app-containers/reg/Manifest b/app-containers/reg/Manifest new file mode 100644 index 000000000000..315bbbab1f5d --- /dev/null +++ b/app-containers/reg/Manifest @@ -0,0 +1,7 @@ +AUX reg-0.16.0-config.patch 8488 BLAKE2B d1c60fe817ef722f522ecd7503a7000b065c01853a01c22c2c37b1c0d10f8062c73636b40565f65de885e8fb583d318230e0c0ed8ca8f958f48369d14595089d SHA512 05a30d6cd08ff823be993cba4089d2290f6f58272c50f79ed3d84c915cdf5154789f9f809e4225b39397eab16052d1a5f002e43794d992184bc9528c2d378ccf +AUX reg.confd 68 BLAKE2B 90fbc7677653b2e1389a0a0dd4c06f8a108fc70f6ae8d53fb94a5ef4669296679cf0f15bf985594837b0d455206f1b928df8a65596e81c0c717c5908c1987b0c SHA512 c0e7e68e8fd09cd46af3a01dc3507ef55dc25016b00e425e673734c864f05c63fcf3dc10b7ca987f166b33cfbfea62ca6c3458b73e28d3683d5bc81cbda84c4e +AUX reg.initd 595 BLAKE2B 36a5fd61c46810c1924c86c00392348e0907501f896114c3c523daebfd110e5ea292d4087fc4a41ba91ccd952c1c6b27fe1b1db60364575352a9eb9e4b207258 SHA512 96919a0d2f29631c4296bcf8adfb78d63f5d732ed350491f7df14f45744c945559110454a0c24726962da7519dd790a37a6c6a2e0d3586599dc7231743fbe03a +DIST github.com-go-yaml-yaml-eb3733d160e7.tar.gz 64789 BLAKE2B a59db73ba751c932695913770550e115d46df28c4cff402325cf5324c97069e3acccb9faf39826a5da416f8c5b0cc69377cef41a6b1451afa82c7ae8bd620544 SHA512 9e34c34c907d1177e072eb5f3b421b8a3af0e68b490508691d745cdcf1145d9bcfd2592d909a4b05e7f12bfb62355d49861f6d2e1bd29b69cf026ef631965289 +DIST reg-0.16.1.tar.gz 3163977 BLAKE2B b161200e7b96b26054e121853bafb4751865de1146f07fa48418a6624beeebd10eb8fcde1af90f9dd3c20ffd8d5807a106d012bf996944c96b5ff841b0079fb4 SHA512 77fbd543de6e94c504e98a0364895b19099e3cde55a85a4413730de58de8e84f50889fdcfaffa1c76ae412a603ed6d5f4b1d57566ec814cf88df70278e91aee6 +EBUILD reg-0.16.1.ebuild 1363 BLAKE2B 6ed76524b8f00b8669886f214f2cb702e93b89cf1d44db5373e7ff60830c1dd94e1a26ef95711cae8958a7a2ded0e1ce4b9638aa03fb22ba082a695961d6c080 SHA512 d31c2dcc3d1e1b1f1ddfc1563c49441670602a2ed345ffa78b0e7a3e1edc98ca1b04cc1c77395724704bf5331189e99683564176937df5cf8d98fffcd0e43f9f +MISC metadata.xml 330 BLAKE2B 737fada2e7d6372eabfe0187e1c499e307404c111718319f57a825b2c997e1599fd9081f2ec357bab008f1e58312222080887a724f725a9245891b54c5652208 SHA512 150d486491972769b48b1cf2e7b867d81ed23ed86ea3f08d9d22b245d925f2adac514c51927d0bda94a252329c393378d71a9d0120eb794aae65c405390c972c diff --git a/app-containers/reg/files/reg-0.16.0-config.patch b/app-containers/reg/files/reg-0.16.0-config.patch new file mode 100644 index 000000000000..3ec1bf44d032 --- /dev/null +++ b/app-containers/reg/files/reg-0.16.0-config.patch @@ -0,0 +1,254 @@ +From 0ab86b565f437b9dede5d3a7cef56690d8d19bbb Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Manuel=20R=C3=BCger?= <manuel@rueg.eu> +Date: Tue, 18 Sep 2018 15:42:24 +0200 +Subject: [PATCH 2/2] server: Read config from file + +--- + README.md | 4 ++ + config.yml.example | 37 ++++++++++++++++ + server.go | 107 +++++++++++++++++++++++++++++++-------------- + 3 files changed, 114 insertions(+), 34 deletions(-) + create mode 100644 config.yml.example + +diff --git a/README.md b/README.md +index 3b1b661f..5e0f0175 100644 +--- a/README.md ++++ b/README.md +@@ -228,6 +228,7 @@ Flags: + -u, --username username for the registry (default: <none>) + --listen-address address to listen on (default: <none>) + --asset-path Path to assets and templates (default: <none>) ++ --config Path to config file (default: <none>) + -f, --force-non-ssl force allow use of non-ssl (default: false) + --once generate the templates once and then exit (default: false) + --skip-ping skip pinging the registry while establishing connection (default: false) +@@ -243,6 +244,9 @@ Flags: + -p, --password password for the registry (default: <none>) + ``` + ++Alternatively you can provide configuration to `reg server` via a file passed to ++`reg server` via as `--config`. See also config.yml.example in this repository. ++ + **Screenshots:** + + ![home.png](server/home.png) +diff --git a/config.yml.example b/config.yml.example +new file mode 100644 +index 00000000..9d4be25f +--- /dev/null ++++ b/config.yml.example +@@ -0,0 +1,37 @@ ++### Reg Server Settings ++ ++## Path to server TLS certificate: ++# cert: ++## Path to server TLS key: ++# key: ++## Address to listen on: ++# listen-address: 0.0.0.0 ++## Port to listen on: ++# port: 8080 ++## Path Assets are stored under: ++# asset-path: /var/lib/reg ++## Generate static website and exit: ++# once: false ++## Refresh interval: ++# interval: 1h0m0s ++## Debug output ++# debug: false ++## Skip initial ping ++# skip-ping: false ++## Timeout ++# timeout: 1m0s ++ ++ ++### Registry and Clair Server Settings ++## Registry Server: ++# registry: r.j3ss.co ++## Username to authenticate against registry server ++# username: ++## Password to authenticate against registry server ++# password: ++## If true, do not verify TLS certificates ++# insecure: false ++## Force allow use of non-TLS connections ++# force-nonssl: false ++## Clair Server: ++# clair: +diff --git a/server.go b/server.go +index fcd4cd71..0c84d85d 100644 +--- a/server.go ++++ b/server.go +@@ -4,7 +4,9 @@ import ( + "context" + "flag" + "fmt" ++ "gopkg.in/yaml.v2" + "html/template" ++ "io/ioutil" + "net/http" + "os" + "path/filepath" +@@ -29,39 +31,76 @@ func (cmd *serverCommand) LongHelp() string { return serverHelp } + func (cmd *serverCommand) Hidden() bool { return false } + + func (cmd *serverCommand) Register(fs *flag.FlagSet) { +- fs.DurationVar(&cmd.interval, "interval", time.Hour, "interval to generate new index.html's at") ++ fs.DurationVar(&cmd.Interval, "interval", time.Hour, "interval to generate new index.html's at") + +- fs.StringVar(&cmd.registryServer, "registry", "", "URL to the private registry (ex. r.j3ss.co)") +- fs.StringVar(&cmd.registryServer, "r", "", "URL to the private registry (ex. r.j3ss.co)") ++ fs.StringVar(&cmd.RegistryServer, "registry", "", "URL to the private registry (ex. r.j3ss.co)") ++ fs.StringVar(&cmd.RegistryServer, "r", "", "URL to the private registry (ex. r.j3ss.co)") + +- fs.StringVar(&cmd.clairServer, "clair", "", "url to clair instance") ++ fs.StringVar(&cmd.ClairServer, "clair", "", "url to clair instance") + +- fs.StringVar(&cmd.cert, "cert", "", "path to ssl cert") +- fs.StringVar(&cmd.key, "key", "", "path to ssl key") +- fs.StringVar(&cmd.listenAddress, "listen-address", "", "address to listen on") +- fs.StringVar(&cmd.port, "port", "8080", "port for server to run on") +- fs.StringVar(&cmd.assetPath, "asset-path", "", "Path to assets and templates") ++ fs.StringVar(&cmd.Cert, "cert", "", "path to ssl cert") ++ fs.StringVar(&cmd.Key, "key", "", "path to ssl key") ++ fs.StringVar(&cmd.ListenAddress, "listen-address", "", "address to listen on") ++ fs.StringVar(&cmd.Port, "port", "8080", "port for server to run on") + +- fs.BoolVar(&cmd.generateAndExit, "once", false, "generate the templates once and then exit") ++ fs.StringVar(&cmd.AssetPath, "asset-path", "", "Path to assets and templates") ++ fs.StringVar(&cmd.configPath, "config", "", "Path to config file") ++ ++ fs.BoolVar(&cmd.GenerateAndExit, "once", false, "generate the templates once and then exit") + } + + type serverCommand struct { +- interval time.Duration +- registryServer string +- clairServer string +- +- generateAndExit bool +- +- cert string +- key string +- listenAddress string +- port string +- assetPath string ++ Interval time.Duration `yaml:"interval"` ++ RegistryServer string `yaml:"registry"` ++ ClairServer string `yaml:"clair"` ++ GenerateAndExit bool `yaml:"once"` ++ Cert string `yaml:"cert"` ++ Key string `yaml:"key"` ++ ListenAddress string `yaml:"listen-address"` ++ Port string `yaml:"port"` ++ AssetPath string `yaml:"asset-path"` ++ configPath string ++ ++ Password string `yaml:"password"` ++ Username string `yaml:"username"` ++ Insecure bool `yaml:"insecure"` ++ Debug bool `yaml:"debug"` ++ SkipPing bool `yaml:"skip-ping"` ++ ForceNonSSL bool `yaml:"force-nonssl"` ++ Timeout time.Duration `yaml:"timeout"` + } + + func (cmd *serverCommand) Run(ctx context.Context, args []string) error { + // Create the registry client. +- r, err := createRegistryClient(ctx, cmd.registryServer) ++ if len(cmd.configPath) > 0 { ++ config, err := ioutil.ReadFile(cmd.configPath) ++ if err != nil { ++ return err ++ } ++ yaml.Unmarshal(config, cmd) ++ if err != nil { ++ return err ++ } ++ if len(cmd.Username) > 0 { ++ username = cmd.Username ++ } ++ if len(cmd.Password) > 0 { ++ password = cmd.Password ++ } ++ if cmd.Debug { ++ debug = cmd.Debug ++ } ++ if cmd.Insecure { ++ insecure = cmd.Insecure ++ } ++ if cmd.SkipPing { ++ skipPing = cmd.SkipPing ++ } ++ if cmd.Timeout != 0 { ++ timeout = cmd.Timeout ++ } ++ } ++ r, err := createRegistryClient(ctx, cmd.RegistryServer) + if err != nil { + return err + } +@@ -69,25 +108,25 @@ func (cmd *serverCommand) Run(ctx context.Context, args []string) error { + // Create the registry controller for the handlers. + rc := registryController{ + reg: r, +- generateOnly: cmd.generateAndExit, ++ generateOnly: cmd.GenerateAndExit, + } + + // Create a clair client if the user passed in a server address. +- if len(cmd.clairServer) > 0 { +- rc.cl, err = clair.New(cmd.clairServer, clair.Opt{ ++ if len(cmd.ClairServer) > 0 { ++ rc.cl, err = clair.New(cmd.ClairServer, clair.Opt{ + Insecure: insecure, + Debug: debug, + Timeout: timeout, + }) + if err != nil { +- return fmt.Errorf("creation of clair client at %s failed: %v", cmd.clairServer, err) ++ return fmt.Errorf("creation of clair client at %s failed: %v", cmd.ClairServer, err) + } + } else { + rc.cl = nil + } + // Get the path to the asset directory. +- assetDir := cmd.assetPath +- if len(cmd.assetPath) <= 0 { ++ assetDir := cmd.AssetPath ++ if len(cmd.AssetPath) <= 0 { + assetDir, err = os.Getwd() + if err != nil { + return err +@@ -131,12 +170,12 @@ func (cmd *serverCommand) Run(ctx context.Context, args []string) error { + return fmt.Errorf("creating index failed: %v", err) + } + +- if cmd.generateAndExit { ++ if cmd.GenerateAndExit { + logrus.Info("output generated, exiting...") + return nil + } + +- rc.interval = cmd.interval ++ rc.interval = cmd.Interval + ticker := time.NewTicker(rc.interval) + go func() { + // Create more indexes every X minutes based off interval. +@@ -174,12 +213,12 @@ func (cmd *serverCommand) Run(ctx context.Context, args []string) error { + + // Set up the server. + server := &http.Server{ +- Addr: cmd.listenAddress + ":" + cmd.port, ++ Addr: cmd.ListenAddress + ":" + cmd.Port, + Handler: mux, + } +- logrus.Infof("Starting server on port %q", cmd.port) +- if len(cmd.cert) > 0 && len(cmd.key) > 0 { +- return server.ListenAndServeTLS(cmd.cert, cmd.key) ++ logrus.Infof("Starting server on port %q", cmd.Port) ++ if len(cmd.Cert) > 0 && len(cmd.Key) > 0 { ++ return server.ListenAndServeTLS(cmd.Cert, cmd.Key) + } + return server.ListenAndServe() + } diff --git a/app-containers/reg/files/reg.confd b/app-containers/reg/files/reg.confd new file mode 100644 index 000000000000..1bd2475decc4 --- /dev/null +++ b/app-containers/reg/files/reg.confd @@ -0,0 +1,2 @@ +# arguments for reg server +command_args="--asset-path=/var/lib/reg" diff --git a/app-containers/reg/files/reg.initd b/app-containers/reg/files/reg.initd new file mode 100644 index 000000000000..7759f44f376c --- /dev/null +++ b/app-containers/reg/files/reg.initd @@ -0,0 +1,19 @@ +#!/sbin/openrc-run +# Copyright 2016-2018 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +description="Reg server - providing a UI for Docker Registry" +pidfile=${pidfile:-"/run/${RC_SVCNAME}.pid"} +user=${user:-${RC_SVCNAME}} +group=${group:-${RC_SVCNAME}} + +command="/usr/bin/reg server" +command_args="${command_args:---asset-path=/var/lib/reg}" +command_background="true" +start_stop_daemon_args="--user ${user} --group ${group} \ + --stdout /var/log/${RC_SVCNAME}/${RC_SVCNAME}.log \ + --stderr /var/log/${RC_SVCNAME}/${RC_SVCNAME}.log" + +depend() { + after net +} diff --git a/app-containers/reg/metadata.xml b/app-containers/reg/metadata.xml new file mode 100644 index 000000000000..0d1d641a5742 --- /dev/null +++ b/app-containers/reg/metadata.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> + <maintainer type="person"> + <email>williamh@gentoo.org</email> + <name>William Hubbs</name> + </maintainer> + <upstream> + <remote-id type="github">genuinetools/reg</remote-id> + </upstream> +</pkgmetadata> diff --git a/app-containers/reg/reg-0.16.1.ebuild b/app-containers/reg/reg-0.16.1.ebuild new file mode 100644 index 000000000000..bfd5ac25d064 --- /dev/null +++ b/app-containers/reg/reg-0.16.1.ebuild @@ -0,0 +1,54 @@ +# Copyright 1999-2019 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 + +EGO_VENDOR=( "gopkg.in/yaml.v2 eb3733d160e7 github.com/go-yaml/yaml" ) + +inherit golang-build golang-vcs-snapshot user + +EGO_PN="github.com/genuinetools/reg" +GIT_COMMIT="4203e559f331009df04a3ca47820989c6c43e138" +ARCHIVE_URI="https://${EGO_PN}/archive/${GIT_COMMIT}.tar.gz -> ${P}.tar.gz + ${EGO_VENDOR_URI}" +KEYWORDS="~amd64" + +DESCRIPTION="Docker registry v2 command line client" +HOMEPAGE="https://github.com/genuinetools/reg" +SRC_URI="${ARCHIVE_URI}" +LICENSE="MIT Apache-2.0 BSD BSD-2 CC-BY-SA-4.0 ISC" +SLOT="0" +IUSE="" + +RESTRICT="test" + +pkg_setup() { + enewgroup reg + enewuser reg -1 -1 /var/lib/reg reg +} + +src_prepare() { + pushd src/${EGO_PN} || die + eapply "${FILESDIR}"/reg-0.16.0-config.patch + default + popd || die +} + +src_compile() { + export -n GOCACHE GOPATH XDG_CACHE_HOME + pushd src/${EGO_PN} || die + GO111MODULE=on go build -mod=vendor -v -ldflags "-X ${EGO_PN}/version.GITCOMMIT=${GIT_COMMIT} -X ${EGO_PN}/version.VERSION=${PV}" -o "${S}"/bin/reg . || die + popd || die +} + +src_install() { + dobin bin/* + dodoc src/${EGO_PN}/README.md + insinto /var/lib/${PN} + doins -r src/${EGO_PN}/server/* + newinitd "${FILESDIR}"/reg.initd reg + newconfd "${FILESDIR}"/reg.confd reg + + keepdir /var/log/reg + fowners -R reg:reg /var/log/reg /var/lib/reg/static +} |