GitLab Package Registry administration
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
编辑
/etc/gitlab/gitlab.rb
并添加以下行:gitlab_rails['packages_enabled'] = true
保存文件并重新配置 GitLab,以使更改生效.
从源安装
安装完成后,您将必须在
config/gitlab.yml
中config/gitlab.yml
packages
部分. 设置为true
以启用它:packages:
enabled: true
重新启动 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
编辑
/etc/gitlab/gitlab.rb
并添加以下行:gitlab_rails['packages_storage_path'] = "/mnt/packages"
保存文件并重新配置 GitLab,以使更改生效.
从源安装
编辑
config/gitlab.yml
的packages
部分:packages:
enabled: true
storage_path: shared/packages
保存文件并重新启动 GitLab,以使更改生效.
Using object storage
您可以使用对象存储来存储程序包,而不必依赖于本地存储.
Read more about using object storage with GitLab.
注意:我们建议使用统一对象存储设置 . 以下说明适用于原始配置格式.
Omnibus GitLab installations
编辑
/etc/gitlab/gitlab.rb
并添加以下行(必要时取消注释):gitlab_rails['packages_enabled'] = true
gitlab_rails['packages_storage_path'] = "/var/opt/gitlab/gitlab-rails/shared/packages"
gitlab_rails['packages_object_store_enabled'] = true
gitlab_rails['packages_object_store_remote_directory'] = "packages" # The bucket name.
gitlab_rails['packages_object_store_direct_upload'] = false # Use Object Storage directly for uploads instead of background uploads if enabled (Default: false).
gitlab_rails['packages_object_store_background_upload'] = true # Temporary option to limit automatic upload (Default: true).
gitlab_rails['packages_object_store_proxy_download'] = false # Passthrough all downloads via GitLab instead of using Redirects to Object Storage.
gitlab_rails['packages_object_store_connection'] = {
##
## If the provider is AWS S3, uncomment the following
##
#'provider' => 'AWS',
#'region' => 'eu-west-1',
#'aws_access_key_id' => 'AWS_ACCESS_KEY_ID',
#'aws_secret_access_key' => 'AWS_SECRET_ACCESS_KEY',
##
## If the provider is other than AWS (an S3-compatible one), uncomment the following
##
#'host' => 's3.amazonaws.com',
#'aws_signature_version' => 4 # For creation of signed URLs. Set to 2 if provider does not support v4.
#'endpoint' => 'https://s3.amazonaws.com' # Useful for S3-compliant services such as DigitalOcean Spaces.
#'path_style' => false # If true, use 'host/bucket_name/object' instead of 'bucket_name.host/object'.
}
保存文件并重新配置 GitLab,以使更改生效.
从源安装
编辑
config/gitlab.yml
的packages
部分(必要时取消注释):packages:
enabled: true
##
## The location where build packages are stored (default: shared/packages).
##
#storage_path: shared/packages
object_store:
enabled: false
remote_directory: packages # The bucket name.
#direct_upload: false # Use Object Storage directly for uploads instead of background uploads if enabled (Default: false).
#background_upload: true # Temporary option to limit automatic upload (Default: true).
#proxy_download: false # Passthrough all downloads via GitLab instead of using Redirects to Object Storage.
connection:
##
## If the provider is AWS S3, uncomment the following
##
#provider: AWS
#region: us-east-1
#aws_access_key_id: AWS_ACCESS_KEY_ID
#aws_secret_access_key: AWS_SECRET_ACCESS_KEY
##
## If the provider is other than AWS (an S3-compatible one), uncomment the following
##
#host: 's3.amazonaws.com' # default: s3.amazonaws.com.
#aws_signature_version: 4 # For creation of signed URLs. Set to 2 if provider does not support v4.
#endpoint: 'https://s3.amazonaws.com' # Useful for S3-compliant services such as DigitalOcean Spaces.
#path_style: false # If true, use 'host/bucket_name/object' instead of 'bucket_name.host/object'.
保存文件并重新启动 GitLab,以使更改生效.
Migrating local packages to object storage
配置对象存储后 ,您可以使用以下任务将现有程序包从本地存储迁移到远程存储. 该处理将在后台工作人员中完成, 无需停机 .
对于所有 GitLab;
sudo gitlab-rake "gitlab:packages:migrate"
对于源安装:
RAILS_ENV=production sudo -u git -H bundle exec rake gitlab:packages:migrate