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

Next #395

Closed
wants to merge 14 commits into from
Closed

Next #395

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dotcloudignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
contrib
.tox
reports
test
tests
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ eggs
Vagrantfile
.vagrant

docker-registry-core.sublime-workspace

*tmp

*.sublime-workspace
*.sublime-project
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ python:
install:
## This below should be separated when core lives elsewhere
# Install core tests reqs
- pip install -rdepends/docker-registry-core/tests/requirements-tests.txt
- pip install -rdepends/docker-registry-core/tests/requirements-style.txt
- pip install -rdepends/docker-registry-core/requirements-test.txt
- pip install -rdepends/docker-registry-core/requirements-style.txt
# Install core itself
- pip install depends/docker-registry-core/

# Install our tests requirements, and ourselves
- pip install -rtests/requirements.txt
- pip install -rrequirements-test.txt
- pip install .

# XXX should run the core tests as well
Expand All @@ -22,5 +22,3 @@ script: SETTINGS_FLAVOR=test DOCKER_REGISTRY_CONFIG=config_sample.yml flake8 . &
before_install:
- sudo apt-get update
- sudo apt-get install libevent-dev liblzma-dev

# build-essential python-dev
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Ken Cochrane <[email protected]>
Kevin Clark <[email protected]>
Leon Xiang <[email protected]>
Lucas Clemente <[email protected]>
Mangled Deutz <[email protected]>
Marc Tamsky <[email protected]>
Marek Goldmann <[email protected]>
Mario Rodas <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Major architecture rehaul, with potentially breaking changes:
* largely enhanced configuration mechanism (setup-configs.sh is no more)
* cookies are no longer used
* CORS is now enabled on a number of endpoints
* extras requirements

* [BUGFIX] unicode issues. Depending on the storage driver you are using, you may encounter unicode issues on already published content (likely garbled content).
* [BUGFIX] content-length fix for bytes ranges
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

## Bare minimum

You need `git`, `pip` and `tox`.
System-wide, you need `git` and `pip`. You also need (`pip`) `tox`.

You might need `nose`, `coverage` and `flake`.
You optionally need (recommended, `pip`) `nose`, `coverage` and `flake`.


## Architecture
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ add ./config/boto.cfg /etc/boto.cfg
run pip install /docker-registry/depends/docker-registry-core

# Install registry
run pip install /docker-registry/
run pip install file:///docker-registry#egg=docker-registry[bugsnag]

env DOCKER_REGISTRY_CONFIG /docker-registry/config/config_sample.yml
env SETTINGS_FLAVOR dev
Expand Down
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include requirements.txt
include tests/requirements.txt
include requirements-test.txt
include requirements-style.txt
include README.md
include LICENSE
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ When using the `config_sample.yml`, you can pass all options through as environm
*non*-Amazon S3-compliant object store, in one of the boto config files'
`[Credentials]` section, set `boto_host`, `boto_port` as appropriate for the
service you are using.
1. `bugsnag`: The bugsnag API key
1. `bugsnag`: The bugsnag API key (note that if you don't use the official docker container, you need to install the registry with bugsnag enabled: `pip install docker-registry[bugsnag]`)

### Authentication options

Expand Down Expand Up @@ -404,6 +404,13 @@ Then install the Registry app:
sudo pip install docker-registry
```

If you need extra requirements, like bugsnag, specify them:

```
sudo pip install docker-registry[bugsnag]
```


(or clone the repository and `pip install .`)

#### On Red Hat-based systems:
Expand All @@ -420,7 +427,7 @@ should not require the additional repositories.
Then install the Registry app:

```
sudo python-pip install docker-registry
sudo python-pip install docker-registry[bugsnag]
```

(or clone the repository and `pip install .`)
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cd $SERVICE_APPROOT
. ~/env/bin/activate

pip install --download-cache=~/.pip-cache ./depends/docker-registry-core || exit 1
pip install --download-cache=~/.pip-cache . || exit 1
pip install --download-cache=~/.pip-cache file://`pwd`#egg=docker-registry[bugsnag] || exit 1

cp -R * ~/

Expand Down
7 changes: 4 additions & 3 deletions contrib/docker-registry.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ env REGISTRY_DIR=/srv/docker/registry
env USER=www-data
env GROUP=www-data
env LOG_FILE=/var/log/docker/registry.log
env NUM_WORKERS=9
env GUNICORN_WORKERS=9

env ADDRESS=127.0.0.1:5000
env REGISTRY_PORT=5000
env REGISTRY_HOST=127.0.0.1


pre-start script
Expand All @@ -27,5 +28,5 @@ script

[ -r $REGISTRY_DIR/.venv/bin/activate ] && . $REGISTRY_DIR/.venv/bin/activate
cd $REGISTRY_DIR
exec gunicorn -w $NUM_WORKERS --bind=$ADDRESS --user=$USER --group=$GROUP --log-level=$LOG_LEVEL --log-file=$LOG_FILE 2>>$LOG_FILE wsgi:application
exec gunicorn -w $GUNICORN_WORKERS --bind=$REGISTRY_HOST:$REGISTRY_PORT --user=$USER --group=$GROUP --log-level=$LOG_LEVEL --log-file=$LOG_FILE 2>>$LOG_FILE docker_registry.wsgi:application
end script
2 changes: 1 addition & 1 deletion contrib/docker-registry_RHEL.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ self_dir="${self_path%%/${self_path##*/}}"

NAME="Docker Registry"
DAEMON="/usr/bin/gunicorn"
DAEMON_OPTS="-D --error-logfile ${ERROR_LOGFILE} --access-logfile ${ACCESS_LOGFILE} --log-file ${LOGFILE} --pid ${PIDFILE} --max-requests 500 --graceful-timeout 3600 -t 3600 -k gevent -b ${LISTEN_IP}:${LISTEN_PORT} -w ${GUNICORN_WORKERS:-2} wsgi:application"
DAEMON_OPTS="-D --error-logfile ${ERROR_LOGFILE} --access-logfile ${ACCESS_LOGFILE} --log-file ${LOGFILE} --pid ${PIDFILE} --max-requests 500 --graceful-timeout 3600 -t 3600 -k gevent -b ${LISTEN_IP}:${LISTEN_PORT} -w ${GUNICORN_WORKERS:-2} docker_registry.wsgi:application"

RED='\e[0;31m'
GREEN='\e[0;32m'
Expand Down
6 changes: 3 additions & 3 deletions contrib/docker-registry_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Default-Stop: 0 1 6
# Short-Description: Start Docker-Registry
### END INIT INFO

Expand Down Expand Up @@ -33,15 +33,15 @@ self_dir="${self_path%%/${self_path##*/}}"
# set defaults if they are not set by config
[[ -z "$RUNAS" ]] && RUNAS=$(stat --format "%U" $self_path) # defaults to user owning this init script
[[ -z "$LOGFILE" ]] && LOGFILE=/var/log/docker-registry.log # will be chowned to $RUNAS
[[ -z "$PIDFILE" ]] && PIDFILE=/var/run/docker-registry/docker-registry.pid # path will created and chowned to $RUNAS
[[ -z "$PIDFILE" ]] && PIDFILE=/var/run/docker-registry/docker-registry.pid # path will created and chowned to $RUNAS
[[ -z "$LISTEN_IP" ]] && LISTEN_IP="0.0.0.0"
[[ -z "$LISTEN_PORT" ]] && LISTEN_PORT=5000
[[ -z "$GUNICORN_WORKERS" ]] && GUNICORN_WORKERS=2
[[ -z "$DOCKER_REGISTRY_HOME" ]] && DOCKER_REGISTRY_HOME=${self_dir%/*}

NAME="Docker Registry"
DAEMON="/usr/local/bin/gunicorn"
DAEMON_OPTS="-D --access-logfile ${LOGFILE} --pid ${PIDFILE} --max-requests 500 --graceful-timeout 3600 -t 3600 -k gevent -b ${LISTEN_IP}:${LISTEN_PORT} -w ${GUNICORN_WORKERS:-2} wsgi:application"
DAEMON_OPTS="-D --access-logfile ${LOGFILE} --pid ${PIDFILE} --max-requests 500 --graceful-timeout 3600 -t 3600 -k gevent -b ${LISTEN_IP}:${LISTEN_PORT} -w ${GUNICORN_WORKERS:-2} docker_registry.wsgi:application"

RED='\e[0;31m'
GREEN='\e[0;32m'
Expand Down
4 changes: 2 additions & 2 deletions depends/docker-registry-core/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ python:
- "3.4"

install:
- pip install -rtests/requirements-test.txt
- pip install -rtests/requirements-style.txt
- pip install -rrequirements-test.txt
- pip install -rrequirements-style.txt
- pip install .

script: flake8 . && python setup.py nosetests
Expand Down
4 changes: 2 additions & 2 deletions depends/docker-registry-core/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include requirements.txt
include tests/requirements-tests.txt
include tests/requirements-style.txt
include requirements-test.txt
include requirements-style.txt
include README.md
include LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
__credits__ = []

__license__ = 'Apache 2.0'
__version__ = '1.0.6'
__version__ = '1.0.7'
__maintainer__ = 'Docker'
__email__ = '[email protected]'
__status__ = 'Production'
Expand Down
10 changes: 7 additions & 3 deletions depends/docker-registry-core/docker_registry/core/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class Base(object):
# By default no storage plugin supports it
supports_bytes_range = False

def __init__(self, path=None, config=None):
pass

# FIXME(samalba): Move all path resolver in each module (out of the base)
def images_list_path(self, namespace, repository):
repository_path = self.repository_path(
Expand Down Expand Up @@ -232,13 +235,14 @@ def fetch(name):
module = __import__('docker_registry.drivers.%s' % name, globals(),
locals(), ['Storage'], 0) # noqa
logger.debug("Will return docker-registry.drivers.%s.Storage" % name)
except ImportError:
except ImportError as e:
logger.warn("Got exception: %s" % e)
raise NotImplementedError(
"""You requested storage driver docker_registry.drivers.%s
which is not installed. Try `pip install docker-registry-driver-%s`
or check your configuration. The following are currently
available on your system: %s"""
% (name, name, available())
available on your system: %s. Exception was: %s"""
% (name, name, available(), e)
)
module.Storage.scheme = name
return module.Storage
Expand Down
15 changes: 13 additions & 2 deletions depends/docker-registry-core/docker_registry/drivers/dumb.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,20 @@ def put_content(self, path, content):
self._storage[path] = content

def remove(self, path):
if path not in self._storage:
# Straight key, delete
if path in self._storage:
del self._storage[path]
return
# Directory like, get the list
ls = []
for k in self._storage.keys():
if (not k == path) and k.startswith(path):
ls.append(k)

if not len(ls):
raise exceptions.FileNotFoundError('%s is not there' % path)
del self._storage[path]
for item in ls:
self.remove(item)

def stream_read(self, path, bytes_range=None):
if path not in self._storage:
Expand Down
24 changes: 24 additions & 0 deletions depends/docker-registry-core/docker_registry/testing/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,30 @@ def test_remove_existent(self):
self._storage.remove(filename)
assert not self._storage.exists(filename)

def test_remove_folder(self):
dirname = self.gen_random_string()
filename1 = self.gen_random_string()
filename2 = self.gen_random_string()
content = self.gen_random_string().encode('utf8')
self._storage.put_content('%s/%s' % (dirname, filename1), content)
self._storage.put_content('%s/%s' % (dirname, filename2), content)
self._storage.remove(dirname)
assert not self._storage.exists(filename1)
assert not self._storage.exists(filename2)
assert not self._storage.exists(dirname)
# Check the lru is ok
try:
self._storage.get_content(filename1)
assert False
except Exception:
pass

try:
self._storage.get_content(filename2)
assert False
except Exception:
pass

@tools.raises(exceptions.FileNotFoundError)
def test_remove_inexistent(self):
filename = self.gen_random_string()
Expand Down
4 changes: 0 additions & 4 deletions depends/docker-registry-core/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,3 @@ cover-package=docker_registry
cover-erase=1
cover-html=1
cover-html-dir=reports

[flake8]
ignore = H304
exclude = .tox,.git,*.egg,build
9 changes: 4 additions & 5 deletions depends/docker-registry-core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import sys

from docker_registry import core # noqa
import docker_registry.core as core

if sys.version_info < (2, 6):
raise Exception("Docker registry requires Python 2.6 or higher.")
Expand All @@ -45,7 +45,8 @@
author_email=core.__email__,
maintainer=core.__maintainer__,
maintainer_email=core.__email__,
url='https://github.com/dotclout/docker-registry',
keywords="docker registry core",
url='https://github.com/dotcloud/docker-registry',
description="Docker registry core package",
long_description=open('./README.md').read(),
# download_url=d,
Expand All @@ -72,8 +73,6 @@
'docker_registry.drivers', 'docker_registry.testing'],
install_requires=requirements,
zip_safe=True,
tests_require="%s\n%s" % (
open('./tests/requirements-tests.txt').read(),
open('./tests/requirements-style.txt').read()),
tests_require=open('./requirements-test.txt').read(),
test_suite='nose.collector'
)
2 changes: 1 addition & 1 deletion depends/docker-registry-core/tests/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from docker_registry import testing
import docker_registry.testing as testing


class TestQueryDumb(testing.Query):
Expand Down
4 changes: 2 additions & 2 deletions depends/docker-registry-core/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ ignore = H304

[testenv]
deps = -rrequirements.txt
-rtests/requirements-tests.txt
-rrequirements-test.txt
commands = python setup.py nosetests

[testenv:flake8]
deps = -rtests/requirements-style.txt
deps = -rrequirements-style.txt
commands = flake8 {toxinidir}
8 changes: 4 additions & 4 deletions docker_registry/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

from . import toolkit
from .lib import config
from .server import __version__

VERSION = '0.7.0'
app = flask.Flask('docker-registry')
cfg = config.load()
loglevel = getattr(logging, cfg.get('loglevel', 'INFO').upper())
Expand All @@ -34,12 +34,12 @@ def ping():
@app.route('/')
def root():
return toolkit.response('docker-registry server ({0}) (v{1})'
.format(cfg.flavor, VERSION))
.format(cfg.flavor, __version__))


@app.after_request
def after_request(response):
response.headers['X-Docker-Registry-Version'] = VERSION
response.headers['X-Docker-Registry-Version'] = __version__
response.headers['X-Docker-Registry-Config'] = cfg.flavor
return response

Expand Down Expand Up @@ -75,7 +75,7 @@ def init():
project_root=root_path,
release_stage=cfg.flavor,
notify_release_stages=[cfg.flavor],
app_version=VERSION
app_version=__version__
)
bugsnag.flask.handle_exceptions(app)

Expand Down
1 change: 1 addition & 0 deletions docker_registry/lib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
1 change: 0 additions & 1 deletion docker_registry/lib/cache.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-

import logging

import redis

from docker_registry.core import lru
Expand Down
Loading