# Create an Alpine Repository

To install or host Alpine packages, creation of an Alpine repository is required. Check out [Nexus Repository Management](https://help.sonatype.com/en/repository-management.html) and [Repository Types](https://help.sonatype.com/en/repository-types.html) to learn more.

## Alpine Proxy Repository

Use Nexus proxy repository when you want to download packages and centralize package caching of external dependencies. To learn more, check [Proxy Repositories](https://help.sonatype.com/en/repository-types.html#proxy-repository-type).

To create a new Alpine proxy repository, take the following steps:

1. Navigate to _Settings_ → _Repository_ → _Repositories_.  
2. Select the _Create repository_ button.  
3. From the list of Recipes, select _alpine (proxy)_.  
4. In the form that appears, complete the required fields.
   
   - Repository Name, for example _alpine-proxy_  
   - Remote storage URL, for example [https://dl-cdn.alpinelinux.org/alpine/](https://dl-cdn.alpinelinux.org/alpine/)  
   - Blob store

5. Configure Alpine signing settings as required by your repository setup. For more details, see [Generate an Alpine Signing Key](https://help.sonatype.com/en/create-an-alpine-repository.html#generate-an-alpine-signing-key).
6. Complete the additional fields for configurations you wish to add for creating your repository. Available configurations differ by repository format and type. See [Configurable Repository Fields](https://help.sonatype.com/en/configurable-repository-fields.html) for more details.
7. Select _Create repository_.

## Alpine Hosted Repository

Use Nexus hosted repository when you want to publish and store your own internal artifacts and third party components, so they can be consumed via Nexus. To learn more, check [Hosted Repositories](https://help.sonatype.com/en/repository-types.html#hosted-repository-type).

To create a new Alpine hosted repository, take the following steps:

1. Navigate to _Settings_ → _Repository_ → _Repositories_.  
2. Select the _Create repository_ button.  
3. From the list of Recipes, select _alpine (hosted)_.  
4. In the form that appears, complete the required fields.
   
   - Repository Name, for example _alpine-hosted_  
   - Blob store

## Alpine Group Repository

Use Nexus group repository when you want to combine multiple other repositories (proxy, hosted, and other groups) and expose them through a single URL. To learn more, check [Group Repositories](https://help.sonatype.com/en/repository-types.html#group-repository-type).

To create a new Alpine group repository, take the following steps:

1. Navigate to _Settings_ → _Repository_ → _Repositories_.  
2. Select the _Create repository_ button.  
3. From the list of Recipes, select _alpine (group)_.  
4. In the form that appears, complete the required fields.
   
   - Repository Name, for example _alpine-group_  
   - Blob store  
   - Member repositories in the desired order

## Generate an Alpine Signing Key

Use an RSA private key in `PKCS#8 PEM` format to sign Alpine repository metadata. Take the following steps to generate and rename the signing key:

1. Generate the 2048-bit RSA key using the following command to save it directly to a file.

```
openssl genrsa 2048 | openssl pkcs8 -topk8 -nocrypt -out alpine-signing.key
```

2. Extract the public key from the private key.

```
openssl rsa -in alpine-signing.key -pubout -out alpine-signing.pub
```

3. Generate the public key filename. Alpine requires the public key to have a specific filename derived from your private key. The filename follows the pattern `key-<hash>.rsa.pub.`

Run the following code to generate the filename:

For Windows:

```
$l = Get-Content alpine-signing.key
$b = ($l[1..($l.Count-2)] -join '') -replace '\s',''
$h = -join ([Security.Cryptography.SHA256]::Create().ComputeHash([Text.Encoding]::ASCII.GetBytes($b)) | ForEach-Object { $_.ToString('x2') })
"key-$($h.Substring(56,8))"
```

For Linux or macOS:

```
sed '1d;$d' alpine-signing.key | tr -d '\n\r ' | sha256sum | awk '{print "key-" substr($1, 57, 8)}'
```

For macOS (using shasum):

```
sed '1d;$d' alpine-signing.key | tr -d '\n\r ' | shasum -a 256 | awk '{print "key-" substr($1, 57, 8)}'
```

4. Rename your public key using the generated filename.
