GitLab Package Registry administration

原文:https://docs.gitlab.com/ee/administration/packages/

GitLab Package Registry administration

GitLab 软件包允许组织将 GitLab 用作各种常见软件包管理器的私有存储库. 用户能够构建和发布程序包,这些程序包可以很容易地作为下游项目中的依赖项使用.

软件包功能允许 GitLab 充当以下内容的存储库:

软件库 Description 在 GitLab 版本中可用
PyPi Repository GitLab PyPi 存储库使 GitLab 中的每个项目都有自己的空间来存储PyPi软件包. 12.10+
Composer Repository GitLab Composer 存储库使 GitLab 中的每个项目都有自己的空间来存储Composer软件包. 13.1+
NuGet Repository GitLab NuGet 存储库使 GitLab 中的每个项目都有自己的空间来存储NuGet软件包. 12.8+
Conan Repository GitLab 柯南存储库使 GitLab 中的每个项目都有自己的空间来存储柯南软件包. 12.4+
Maven Repository GitLab Maven 存储库使 GitLab 中的每个项目都有自己的空间来存储Maven软件包. 11.3+
NPM Registry GitLab NPM 注册表使 GitLab 中的每个项目都有自己的空间来存储NPM软件包. 11.7+
Go Proxy GitLab 的 Go 代理使 GitLab 中的每个项目都可以通过Go 代理协议获取. 13.1+

您没有看到您的包裹管理系统受支持吗? 请考虑为 GitLab 做贡献. 此开发文档将指导您完成该过程.

Enabling the Packages feature

注意:启用”软件包”功能后,默认情况下,存储库可用于所有新项目. 要为现有项目启用它,用户将必须在项目的设置中明确启用它.

要启用包功能:

所有装置 GitLab

  1. 编辑/etc/gitlab/gitlab.rb并添加以下行:

    1. gitlab_rails['packages_enabled'] = true
  2. 保存文件并重新配置 GitLab,以使更改生效.

从源安装

  1. 安装完成后,您将必须在config/gitlab.ymlconfig/gitlab.yml packages部分. 设置为true以启用它:

    1. packages:
    2. enabled: true
  2. 重新启动 GitLab,以使更改生效.

Changing the storage path

默认情况下,程序包存储在本地,但是您可以更改默认的本地位置,甚至使用对象存储.

Changing the local storage path

用于 Omnibus GitLab 安装的软件包存储在/var/opt/gitlab/gitlab-rails/shared/packages/而用于源安装的shared/packages/shared/packages/ (相对于 Git 主目录). 更改本地存储路径:

所有装置 GitLab

  1. 编辑/etc/gitlab/gitlab.rb并添加以下行:

    1. gitlab_rails['packages_storage_path'] = "/mnt/packages"
  2. 保存文件并重新配置 GitLab,以使更改生效.

从源安装

  1. 编辑config/gitlab.ymlpackages部分:

    1. packages:
    2. enabled: true
    3. storage_path: shared/packages
  2. 保存文件并重新启动 GitLab,以使更改生效.

Using object storage

您可以使用对象存储来存储程序包,而不必依赖于本地存储.

Read more about using object storage with GitLab.

注意:我们建议使用统一对象存储设置 . 以下说明适用于原始配置格式.

Omnibus GitLab installations

  1. 编辑/etc/gitlab/gitlab.rb并添加以下行(必要时取消注释):

    1. gitlab_rails['packages_enabled'] = true
    2. gitlab_rails['packages_storage_path'] = "/var/opt/gitlab/gitlab-rails/shared/packages"
    3. gitlab_rails['packages_object_store_enabled'] = true
    4. gitlab_rails['packages_object_store_remote_directory'] = "packages" # The bucket name.
    5. gitlab_rails['packages_object_store_direct_upload'] = false # Use Object Storage directly for uploads instead of background uploads if enabled (Default: false).
    6. gitlab_rails['packages_object_store_background_upload'] = true # Temporary option to limit automatic upload (Default: true).
    7. gitlab_rails['packages_object_store_proxy_download'] = false # Passthrough all downloads via GitLab instead of using Redirects to Object Storage.
    8. gitlab_rails['packages_object_store_connection'] = {
    9. ##
    10. ## If the provider is AWS S3, uncomment the following
    11. ##
    12. #'provider' => 'AWS',
    13. #'region' => 'eu-west-1',
    14. #'aws_access_key_id' => 'AWS_ACCESS_KEY_ID',
    15. #'aws_secret_access_key' => 'AWS_SECRET_ACCESS_KEY',
    16. ##
    17. ## If the provider is other than AWS (an S3-compatible one), uncomment the following
    18. ##
    19. #'host' => 's3.amazonaws.com',
    20. #'aws_signature_version' => 4 # For creation of signed URLs. Set to 2 if provider does not support v4.
    21. #'endpoint' => 'https://s3.amazonaws.com' # Useful for S3-compliant services such as DigitalOcean Spaces.
    22. #'path_style' => false # If true, use 'host/bucket_name/object' instead of 'bucket_name.host/object'.
    23. }
  2. 保存文件并重新配置 GitLab,以使更改生效.

从源安装

  1. 编辑config/gitlab.ymlpackages部分(必要时取消注释):

    1. packages:
    2. enabled: true
    3. ##
    4. ## The location where build packages are stored (default: shared/packages).
    5. ##
    6. #storage_path: shared/packages
    7. object_store:
    8. enabled: false
    9. remote_directory: packages # The bucket name.
    10. #direct_upload: false # Use Object Storage directly for uploads instead of background uploads if enabled (Default: false).
    11. #background_upload: true # Temporary option to limit automatic upload (Default: true).
    12. #proxy_download: false # Passthrough all downloads via GitLab instead of using Redirects to Object Storage.
    13. connection:
    14. ##
    15. ## If the provider is AWS S3, uncomment the following
    16. ##
    17. #provider: AWS
    18. #region: us-east-1
    19. #aws_access_key_id: AWS_ACCESS_KEY_ID
    20. #aws_secret_access_key: AWS_SECRET_ACCESS_KEY
    21. ##
    22. ## If the provider is other than AWS (an S3-compatible one), uncomment the following
    23. ##
    24. #host: 's3.amazonaws.com' # default: s3.amazonaws.com.
    25. #aws_signature_version: 4 # For creation of signed URLs. Set to 2 if provider does not support v4.
    26. #endpoint: 'https://s3.amazonaws.com' # Useful for S3-compliant services such as DigitalOcean Spaces.
    27. #path_style: false # If true, use 'host/bucket_name/object' instead of 'bucket_name.host/object'.
  2. 保存文件并重新启动 GitLab,以使更改生效.

Migrating local packages to object storage

配置对象存储后 ,您可以使用以下任务将现有程序包从本地存储迁移到远程存储. 该处理将在后台工作人员中完成, 无需停机 .

对于所有 GitLab;

  1. sudo gitlab-rake "gitlab:packages:migrate"

对于源安装:

  1. RAILS_ENV=production sudo -u git -H bundle exec rake gitlab:packages:migrate