Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.

Commit 718ecf0

Browse files
author
Mangled Deutz
committed
Fix #368 and more configuration cleanup
Docker-DCO-1.1-Signed-off-by: Mangled Deutz <[email protected]> (github: dmp42)
1 parent 1ac4228 commit 718ecf0

File tree

8 files changed

+50
-28
lines changed

8 files changed

+50
-28
lines changed

docker_registry/app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
import flask
1414

1515
from . import toolkit
16-
from .lib import __version__
1716
from .lib import config
17+
from .server import __version__
1818

1919
app = flask.Flask('docker-registry')
2020
cfg = config.load()

docker_registry/lib/__init__.py

-17
Original file line numberDiff line numberDiff line change
@@ -1,18 +1 @@
11
# -*- coding: utf-8 -*-
2-
3-
__author__ = 'Docker Registry Contributors'
4-
__copyright__ = '{{driver.copyright}}'
5-
__credits__ = []
6-
7-
__license__ = 'Apache 2.0'
8-
__version__ = '0.7.0'
9-
__maintainer__ = __author__
10-
__email__ = '[email protected]'
11-
__status__ = 'Production'
12-
13-
__title__ = 'docker-registry'
14-
__build__ = 0x000000
15-
16-
__url__ = 'https://github.com/dotcloud/docker-registry'
17-
__description__ = 'Registry server for Docker'
18-
__download__ = 'https://github.com/dotcloud/docker-registry/archive/master.zip'

docker_registry/lib/cache.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf-8 -*-
22

33
import logging
4-
54
import redis
65

76
from docker_registry.core import lru

docker_registry/run.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from .tags import * # noqa
1717
from .images import * # noqa
1818
from .lib import config
19+
from .server import env
1920
from .status import * # noqa
2021
from .search import * # noqa
2122

@@ -47,12 +48,13 @@ def run_gunicorn():
4748
formatter_class=RawTextHelpFormatter)
4849
parser.parse_args()
4950

50-
workers = os.environ.get('GUNICORN_WORKERS', '4')
51-
port = os.environ.get('REGISTRY_PORT', '5000')
52-
graceful_timeout = os.environ.get('GUNICORN_GRACEFUL_TIMEOUT', '3600')
53-
silent_timeout = os.environ.get('GUNICORN_SILENT_TIMEOUT', '3600')
51+
workers = env.source('GUNICORN_WORKERS')
52+
host = env.source('REGISTRY_HOST')
53+
port = env.source('REGISTRY_PORT')
54+
graceful_timeout = env.source('GUNICORN_GRACEFUL_TIMEOUT')
55+
silent_timeout = env.source('GUNICORN_SILENT_TIMEOUT')
5456

55-
address = '0.0.0.0:{0}'.format(port)
57+
address = '%s:%s' % (host, port)
5658

5759
gunicorn_path = distutils.spawn.find_executable('gunicorn')
5860
if gunicorn_path is None:

docker_registry/server/__init__.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- coding: utf-8 -*-
2+
3+
__author__ = 'Docker Registry Contributors'
4+
__copyright__ = 'Copyright 2014 Docker'
5+
__credits__ = []
6+
7+
__license__ = 'Apache 2.0'
8+
__version__ = '0.7.0'
9+
__maintainer__ = __author__
10+
__email__ = '[email protected]'
11+
__status__ = 'Production'
12+
13+
__title__ = 'docker-registry'
14+
__build__ = 0x000000
15+
16+
__url__ = 'https://github.com/dotcloud/docker-registry'
17+
__description__ = 'Registry server for Docker'
18+
__download__ = 'https://github.com/dotcloud/docker-registry/archive/master.zip'

docker_registry/server/env.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import os
4+
5+
__all__ = ['source']
6+
7+
defined = {
8+
'REGISTRY_PORT': 5000,
9+
'REGISTRY_HOST': '0.0.0.0',
10+
'SETTINGS_FLAVOR': 'dev',
11+
'GUNICORN_WORKERS': 4,
12+
'GUNICORN_GRACEFUL_TIMEOUT': 3600,
13+
'GUNICORN_SILENT_TIMEOUT': 3600
14+
}
15+
16+
17+
def source(key, override=None):
18+
return os.environ.get(key, defined[key] if key in defined else override)

docker_registry/wsgi.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
# -*- coding: utf-8 -*-
33

44
import logging
5-
import os
65

76
from .run import app
7+
from .server import env
88

99

1010
if __name__ == '__main__':
1111
# Bind to PORT if defined, otherwise default to 5000.
12-
port = int(os.environ.get('PORT_WWW', 5000))
12+
host = env.source('REGISTRY_HOST')
13+
port = int(env.source('REGISTRY_PORT'))
1314
app.debug = True
14-
app.run(host='0.0.0.0', port=port)
15+
app.run(host=host, port=port)
1516
# Or you can run:
1617
# gunicorn --access-logfile - --log-level debug --debug -b 0.0.0.0:5000 \
1718
# -w 1 wsgi:application

setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
# XXX as ugly as this looks, namespaces break terribly otherwise
1212
# import docker_registry.lib as lib
13-
execfile('./docker_registry/lib/__init__.py')
13+
execfile('./docker_registry/server/__init__.py')
1414

1515
requirements_txt = open('./requirements.txt')
1616
requirements = [line for line in requirements_txt]
@@ -31,6 +31,7 @@
3131
# Explicit packages list to avoid setup_tools funkyness
3232
packages = ['docker_registry',
3333
'docker_registry.drivers',
34+
'docker_registry.server',
3435
'docker_registry.lib',
3536
'docker_registry.storage',
3637
'docker_registry.lib.index']

0 commit comments

Comments
 (0)