Skip to content

Latest commit

 

History

History
205 lines (159 loc) · 6.47 KB

README-zhCN.md

File metadata and controls

205 lines (159 loc) · 6.47 KB

Docker registry ufile driver

这是基于UFiledocker-registry的存储适配.

License PyPI version

Build Status Coverage Status

目录

部署

准备

  • 一台服务器, 以ubuntu14.04为例
  • python2, 以ubuntu自带的python2为例 (docker-registry因为使用了gevent, 目前仅支持py2)

安装

依赖

sudo apt-get install -y python-dev liblzma-dev libssl-dev swig

virtualenv

virtualenv将不同的python环境隔离. 你可以在这里了解更多

sudo apt-get install -y python-virtualenv
virtualenv docker-registry
cd docker-registry
source bin/activate

安装docker-registry及ufile-driver

pip install docker-registry
pip install docker-registry-driver-ufile

配置和运行

修改下方配置ufile中的内容并存为conf.yml

具体配置请看详细配置. 如果可能, 请使用内网url

common: &common
    issue: '"docker-registry server"'
    # Default log level is info
    loglevel: _env:LOGLEVEL:info
    # Enable debugging (additional informations in the output of the _ping endpoint)
    debug: _env:DEBUG:false
    # By default, the registry acts standalone (eg: doesn't query the index)
    standalone: _env:STANDALONE:true
    # The default endpoint to use (if NOT standalone) is index.docker.io
    index_endpoint: _env:INDEX_ENDPOINT:https://index.docker.io
    # Storage redirect is disabled
    storage_redirect: _env:STORAGE_REDIRECT
    # Token auth is enabled (if NOT standalone)
    disable_token_auth: _env:DISABLE_TOKEN_AUTH
    # No priv key
    privileged_key: _env:PRIVILEGED_KEY
    # No search backend
    search_backend: _env:SEARCH_BACKEND
    # SQLite search backend
    sqlalchemy_index_database: _env:SQLALCHEMY_INDEX_DATABASE:sqlite:////tmp/docker-registry.db

    # Mirroring is not enabled
    mirroring:
        source: _env:MIRROR_SOURCE # https://registry-1.docker.io
        source_index: _env:MIRROR_SOURCE_INDEX # https://index.docker.io
        tags_cache_ttl: _env:MIRROR_TAGS_CACHE_TTL:172800 # seconds

    cache:
        host: _env:CACHE_REDIS_HOST
        port: _env:CACHE_REDIS_PORT
        db: _env:CACHE_REDIS_DB:0
        password: _env:CACHE_REDIS_PASSWORD

    # Enabling LRU cache for small files
    # This speeds up read/write on small files
    # when using a remote storage backend (like S3).
    cache_lru:
        host: _env:CACHE_LRU_REDIS_HOST
        port: _env:CACHE_LRU_REDIS_PORT
        db: _env:CACHE_LRU_REDIS_DB:0
        password: _env:CACHE_LRU_REDIS_PASSWORD

    # Enabling these options makes the Registry send an email on each code Exception
    email_exceptions:
        smtp_host: _env:SMTP_HOST
        smtp_port: _env:SMTP_PORT:25
        smtp_login: _env:SMTP_LOGIN
        smtp_password: _env:SMTP_PASSWORD
        smtp_secure: _env:SMTP_SECURE:false
        from_addr: _env:SMTP_FROM_ADDR:docker-registry@localdomain.local
        to_addr: _env:SMTP_TO_ADDR:noise+dockerregistry@localdomain.local

    # Enable bugsnag (set the API key)
    bugsnag: _env:BUGSNAG

    # CORS support is not enabled by default
    cors:
        origins: _env:CORS_ORIGINS
        methods: _env:CORS_METHODS
        headers: _env:CORS_HEADERS:[Content-Type]
        expose_headers: _env:CORS_EXPOSE_HEADERS
        supports_credentials: _env:CORS_SUPPORTS_CREDENTIALS
        max_age: _env:CORS_MAX_AGE
        send_wildcard: _env:CORS_SEND_WILDCARD
        always_send: _env:CORS_ALWAYS_SEND
        automatic_options: _env:CORS_AUTOMATIC_OPTIONS
        vary_header: _env:CORS_VARY_HEADER
        resources: _env:CORS_RESOURCES

ufile:
      <<: *common
      storage: ufile
      ufile_baseurl: http://your-bucket.ufile.ucloud.cn
      ufile_public_key: your-ucloud-public-key
      ufile_private_key: your-ucloud-private-key
      ufile_retries: 3
      ufile_retry_interval: 1
      ufile_timeout: 60

运行docker-registry并指定运行环境和配置文件

export DOCKER_REGISTRY_CONFIG=`pwd`/config.yml
export SETTINGS_FLAVOR=ufile

docker-registry

试着玩一下

默认的docker-registry监听localhost:5000 你只需要把某个image tag 成 localhost:5000/image-name:tag-name 然后push localhost:5000/image-name:tag-name 即可

详细配置

Driver目前有如下选项可供配置.

ufile_baseurl

ufile bucket地址(含有 http://), 例如:

http://your-bucket.ufile.ucloud.cn

如果可能, 你应该总是使用内网url, 例如 http://your-bucket.ufile.cn-north-03.ucloud.cn

ufile_public_key

ucloud public key, 你可以从控制台获取

ufile_private_key

ucloud private key, 你可以从控制台获取

ufile_retries

如果遇上网络错误, 在失败前重试的次数 (默认3次)

ufile_retry_interval

如果遇上网络错误, 在重试前应等待多少秒 (默认1秒)

ufile_timeout

网络超时 (默认60秒, 如果你只能使用外网的话, 请把这个值改大)

开发

fork后将代码clone到本地

安装tox

pip install tox

开始测试

tox

tox将会安装测试依赖并运行单元测试及pep8测试.

在pull request前, 请确保你本地的tox运行结果都是正确的.

开源许可证

本项目及docker-registry均采用 Apache License.