486.md 8.8 KB
Newer Older
Lab机器人's avatar
readme  
Lab机器人 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
# GitLab Package Registry administration

> 原文:[https://docs.gitlab.com/ee/administration/packages/](https://docs.gitlab.com/ee/administration/packages/)

*   [Enabling the Packages feature](#enabling-the-packages-feature)
*   [Changing the storage path](#changing-the-storage-path)
    *   [Changing the local storage path](#changing-the-local-storage-path)
    *   [Using object storage](#using-object-storage)
    *   [Migrating local packages to object storage](#migrating-local-packages-to-object-storage)

# GitLab Package Registry administration[](#gitlab-package-registry-administration-premium-only "Permalink")

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

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

| 软件库 | Description | 在 GitLab 版本中可用 |
| --- | --- | --- |
| [PyPi Repository](../../user/packages/pypi_repository/index.html) | GitLab PyPi 存储库使 GitLab 中的每个项目都有自己的空间来存储[PyPi](https://s0pypi0org.icopy.site/)软件包. | 12.10+ |
| [Composer Repository](../../user/packages/composer_repository/index.html) | GitLab Composer 存储库使 GitLab 中的每个项目都有自己的空间来存储[Composer](https://s0getcomposer0org.icopy.site/)软件包. | 13.1+ |
| [NuGet Repository](../../user/packages/nuget_repository/index.html) | GitLab NuGet 存储库使 GitLab 中的每个项目都有自己的空间来存储[NuGet](https://www.nuget.org/)软件包. | 12.8+ |
| [Conan Repository](../../user/packages/conan_repository/index.html) | GitLab 柯南存储库使 GitLab 中的每个项目都有自己的空间来存储[柯南](https://conan.io/)软件包. | 12.4+ |
| [Maven Repository](../../user/packages/maven_repository/index.html) | GitLab Maven 存储库使 GitLab 中的每个项目都有自己的空间来存储[Maven](https://maven.apache.org/)软件包. | 11.3+ |
| [NPM Registry](../../user/packages/npm_registry/index.html) | GitLab NPM 注册表使 GitLab 中的每个项目都有自己的空间来存储[NPM](https://s0www0npmjs0com.icopy.site/)软件包. | 11.7+ |
| [Go Proxy](../../user/packages/go_proxy/index.html) | GitLab 的 Go 代理使 GitLab 中的每个项目都可以通过[Go 代理协议](https://proxy.golang.org/)获取. | 13.1+ |

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

## Enabling the Packages feature[](#enabling-the-packages-feature "Permalink")

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

要启用包功能:

**所有装置 GitLab**

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

    ```
    gitlab_rails['packages_enabled'] = true 
    ```

2.  保存文件并[重新配置 GitLab,](../restart_gitlab.html#omnibus-gitlab-reconfigure "如何重新配置​​Omnibus GitLab")以使更改生效.

**从源安装**

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

    ```
    packages:
      enabled: true 
    ```

2.  [重新启动 GitLab,](../restart_gitlab.html#omnibus-gitlab-reconfigure "如何重新配置​​Omnibus GitLab")以使更改生效.

## Changing the storage path[](#changing-the-storage-path "Permalink")

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

### Changing the local storage path[](#changing-the-local-storage-path "Permalink")

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

**所有装置 GitLab**

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

    ```
    gitlab_rails['packages_storage_path'] = "/mnt/packages" 
    ```

2.  保存文件并[重新配置 GitLab,](../restart_gitlab.html#omnibus-gitlab-reconfigure)以使更改生效.

**从源安装**

1.  编辑`config/gitlab.yml``packages`部分:

    ```
    packages:
      enabled: true
      storage_path: shared/packages 
    ```

2.  保存文件并[重新启动 GitLab,](../restart_gitlab.html#installations-from-source)以使更改生效.

### Using object storage[](#using-object-storage "Permalink")

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

[Read more about using object storage with GitLab](../object_storage.html).

**注意:**我们建议使用[统一对象存储设置](../object_storage.html#consolidated-object-storage-configuration) . 以下说明适用于原始配置格式.

**Omnibus GitLab installations**

1.  编辑`/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'.
    } 
    ```

2.  保存文件并[重新配置 GitLab,](../restart_gitlab.html#omnibus-gitlab-reconfigure)以使更改生效.

**从源安装**

1.  编辑`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'. 
    ```

2.  保存文件并[重新启动 GitLab,](../restart_gitlab.html#installations-from-source)以使更改生效.

### Migrating local packages to object storage[](#migrating-local-packages-to-object-storage "Permalink")

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

对于所有 GitLab;

```
sudo gitlab-rake "gitlab:packages:migrate" 
```

对于源安装:

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