|
| 1 | +# Registry Resource |
| 2 | + |
| 3 | +Registry is the configuration that Codefresh uses to push/pull docker images. |
| 4 | +For more details see the [Codefresh Docker Registries](https://codefresh.io/docs/docs/integrations/docker-registries/) |
| 5 | + |
| 6 | + |
| 7 | +## Concurrency Limitation |
| 8 | + |
| 9 | +Codefresh Registry API was not designed initially to handle concurrent modifications on `registry` entity. |
| 10 | +Thus, you need to take one of the following approaches to avoid **errors** and **non-expected behavior**: |
| 11 | + |
| 12 | +1) run terraform write operations with `-parallelism=1` option |
| 13 | +```shell |
| 14 | +terraform apply -parallelism=1 |
| 15 | +terraform destroy -parallelism=1 |
| 16 | +``` |
| 17 | + |
| 18 | +2) make each registry resource `depend_on` each other - so the CRUD operations will be performed for each registry **sequentially** |
| 19 | +```hcl |
| 20 | +resource "codefresh_registry" "dockerhub" { |
| 21 | + name = "dockerhub" |
| 22 | + |
| 23 | + spec { |
| 24 | + dockerhub { |
| 25 | + # some specific fields here |
| 26 | + } |
| 27 | + } |
| 28 | +} |
| 29 | +
|
| 30 | +# this registry will depend on the "dockerhub" registry |
| 31 | +resource "codefresh_registry" "gcr" { |
| 32 | + name = "gcr" |
| 33 | + |
| 34 | + depends_on = [codefresh_registry.dockerhub] |
| 35 | + spec { |
| 36 | + gcr { |
| 37 | + # some specific fields here |
| 38 | + } |
| 39 | + } |
| 40 | +} |
| 41 | +``` |
| 42 | + |
| 43 | +## Supported Registry Providers |
| 44 | + |
| 45 | +Currently, Codefresh supports the following registry providers: |
| 46 | +* dockerhub - [Docker Hub](https://codefresh.io/docs/docs/integrations/docker-registries/docker-hub/) |
| 47 | +* acr - [Azure Container Registry](https://codefresh.io/docs/docs/integrations/docker-registries/azure-docker-registry) |
| 48 | +* gcr - [Google Container Registry](https://codefresh.io/docs/docs/integrations/docker-registries/google-container-registry) |
| 49 | +* gar - [Google Artifact Registry](https://codefresh.io/docs/docs/integrations/docker-registries/google-artifact-registry) |
| 50 | +* ecr - [Amazon EC2 Container Registry](https://codefresh.io/docs/docs/integrations/docker-registries/amazon-ec2-container-registry) |
| 51 | +* bintray - [Bintray / Artifactory](https://codefresh.io/docs/docs/integrations/docker-registries/bintray-io) |
| 52 | +* other - any other provider including [Quay](https://codefresh.io/docs/docs/integrations/docker-registries/quay-io) and [Github Container Registry](https://codefresh.io/docs/docs/integrations/docker-registries/github-container-registry). See the [docs](https://codefresh.io/docs/docs/integrations/docker-registries/other-registries). |
| 53 | + |
| 54 | +### Resource Spec |
| 55 | + |
| 56 | +Each registry resource have some common fields and specific ones stored under the `spec`. Here is the template: |
| 57 | + |
| 58 | +```hcl |
| 59 | +resource "codefresh_registry" "some_registry" { |
| 60 | + name = "some_name" |
| 61 | + default = false |
| 62 | + primary = true |
| 63 | + fallback_registry = codefresh_registry.some_other_registry.id |
| 64 | + |
| 65 | + spec { |
| 66 | + <provider_name> { |
| 67 | + # some specific fields here |
| 68 | + } |
| 69 | + } |
| 70 | +} |
| 71 | +``` |
| 72 | + |
| 73 | + |
| 74 | +### Common fields |
| 75 | + |
| 76 | +* `name` - `(Required)` some unique name for registry |
| 77 | +* `default` - `(Optional, Default = false)` see the [Default Registry](https://codefresh.io/docs/docs/integrations/docker-registries/#the-default-registry) |
| 78 | +* `primary` - `(Optional, Default = true)` see the [Multiple Registries](https://codefresh.io/docs/docs/ci-cd-guides/working-with-docker-registries/#working-with-multiple-registries-with-the-same-domain) |
| 79 | +* `fallback_registry` - `(Optional)` see the [Fallback Registry](https://codefresh.io/docs/docs/integrations/docker-registries/#fallback-registry) |
| 80 | + |
| 81 | + |
| 82 | +### Default registry usage |
| 83 | + |
| 84 | +If you want to manage default registry by Codefresh terraform provider correctly, |
| 85 | +you need to mark only one registry as `default = true` |
| 86 | + |
| 87 | +```hcl |
| 88 | +resource "codefresh_registry" "dockerhub" { |
| 89 | + name = "dockerhub" |
| 90 | + |
| 91 | + spec { |
| 92 | + dockerhub { |
| 93 | + # some specific fields here |
| 94 | + } |
| 95 | + } |
| 96 | +} |
| 97 | +
|
| 98 | +# this registry will be default |
| 99 | +resource "codefresh_registry" "gcr" { |
| 100 | + name = "gcr" |
| 101 | + default = true |
| 102 | + fallback_registry = codefresh_registry.some_other_registry.id |
| 103 | + |
| 104 | + spec { |
| 105 | + gcr { |
| 106 | + # some specific fields here |
| 107 | + } |
| 108 | + } |
| 109 | +} |
| 110 | +``` |
| 111 | + |
| 112 | +### Primary registry usage |
| 113 | + |
| 114 | +If you are using [Multiple Registries](https://codefresh.io/docs/docs/ci-cd-guides/working-with-docker-registries/#working-with-multiple-registries-with-the-same-domain) feature |
| 115 | +you need to manually mark each registry of the same domain as non-primary and only one as primary |
| 116 | + |
| 117 | +```hcl |
| 118 | +# this registry will be primary |
| 119 | +resource "codefresh_registry" "dockerhub" { |
| 120 | + name = "dockerhub" |
| 121 | + primary = true |
| 122 | + |
| 123 | + spec { |
| 124 | + dockerhub { |
| 125 | + # some specific fields here |
| 126 | + } |
| 127 | + } |
| 128 | +} |
| 129 | +
|
| 130 | +resource "codefresh_registry" "dockerhub1" { |
| 131 | + name = "dockerhub1" |
| 132 | + primary = false |
| 133 | +
|
| 134 | + spec { |
| 135 | + dockerhub { |
| 136 | + # some specific fields here |
| 137 | + } |
| 138 | + } |
| 139 | +} |
| 140 | +
|
| 141 | +resource "codefresh_registry" "dockerhub2" { |
| 142 | + name = "dockerhub2" |
| 143 | + primary = false |
| 144 | +
|
| 145 | + spec { |
| 146 | + dockerhub { |
| 147 | + # some specific fields here |
| 148 | + } |
| 149 | + } |
| 150 | +} |
| 151 | +``` |
| 152 | + |
| 153 | +### Fallback registry usage |
| 154 | + |
| 155 | +If you want to use one of your registries as fallback you need to specify its id |
| 156 | +for `fallback_registry` field of another registry |
| 157 | + |
| 158 | +```hcl |
| 159 | +resource "codefresh_registry" "dockerhub" { |
| 160 | + name = "dockerhub" |
| 161 | + |
| 162 | + spec { |
| 163 | + dockerhub { |
| 164 | + # some specific fields here |
| 165 | + } |
| 166 | + } |
| 167 | +} |
| 168 | +
|
| 169 | +resource "codefresh_registry" "gcr" { |
| 170 | + name = "gcr" |
| 171 | + |
| 172 | + # here we take the id of "dockerhub" registry |
| 173 | + fallback_registry = codefresh_registry.dockerhub.id |
| 174 | + |
| 175 | + spec { |
| 176 | + gcr { |
| 177 | + # some specific fields here |
| 178 | + } |
| 179 | + } |
| 180 | +} |
| 181 | +``` |
| 182 | + |
| 183 | +## Argument Reference |
| 184 | + |
| 185 | +- `name` - _(Required)_ some unique name for registry |
| 186 | +- `default` - _(Optional, Default = false)_ default registry |
| 187 | +- `primary` - _(Optional, Default = true)_ primary registry |
| 188 | +- `fallback_registry` - _(Optional)_ fallback registry |
| 189 | +- `spec` - _(Required)_ A `spec` block as documented below. |
| 190 | + |
| 191 | +--- |
| 192 | + |
| 193 | +`spec` supports the following (Note: only 1 of the below can be specified at any time): |
| 194 | + |
| 195 | +- dockerhub - _(Optional)_ A `dockerhub` block as documented below ([Docker Hub Registry](https://codefresh.io/docs/docs/integrations/docker-registries/docker-hub/)) |
| 196 | +- acr - _(Optional)_ An `acr` block as documented below ([Azure Container Registry](https://codefresh.io/docs/docs/integrations/docker-registries/azure-docker-registry)) |
| 197 | +- gcr - _(Optional)_ A `gcr` block as documented below ([Google Container Registry](https://codefresh.io/docs/docs/integrations/docker-registries/google-container-registry)) |
| 198 | +- gar - _(Optional)_ A `gar` block as documented below ([Google Artifact Registry](https://codefresh.io/docs/docs/integrations/docker-registries/google-artifact-registry)) |
| 199 | +- ecr - _(Optional)_ An `ecr` block as documented below ([Amazon EC2 Container Registry](https://codefresh.io/docs/docs/integrations/docker-registries/amazon-ec2-container-registry)) |
| 200 | +- bintray - _(Optional)_ A `bintray` block as documented below ([Bintray / Artifactory](https://codefresh.io/docs/docs/integrations/docker-registries/bintray-io)) |
| 201 | +- other - _(Optional)_ `other` provider block described below ([Other Providers](https://codefresh.io/docs/docs/integrations/docker-registries/other-registries)). |
| 202 | + |
| 203 | + |
| 204 | +--- |
| 205 | + |
| 206 | +`dockerhub` supports the following: |
| 207 | + |
| 208 | +- `username` - _(Required)_ String. |
| 209 | +- `password` - _(Required, Sensitive)_ String. |
| 210 | + |
| 211 | +--- |
| 212 | + |
| 213 | +`acr` supports the following: |
| 214 | + |
| 215 | +- `domain` - _(Required)_ String representing your acr registry domain. |
| 216 | +- `client_id` - _(Required)_ String representing client id. |
| 217 | +- `client_secret` - _(Required)_ String representing client secret. |
| 218 | +- `repository_prefix` - _(Optional)_ String. See the [docs](https://codefresh.io/docs/docs/integrations/docker-registries/#using-an-optional-repository-prefix). |
| 219 | + |
| 220 | +--- |
| 221 | + |
| 222 | +`gcr` supports the following: |
| 223 | + |
| 224 | +- `domain` - _(Required)_ String representing one of the Google's gcr domains |
| 225 | +- `keyfile` - _(Required)_ String representing service account json file contents |
| 226 | +- `repository_prefix` - _(Optional)_ String. See the [docs](https://codefresh.io/docs/docs/integrations/docker-registries/#using-an-optional-repository-prefix). |
| 227 | + |
| 228 | +--- |
| 229 | + |
| 230 | +`gar` supports the following: |
| 231 | + |
| 232 | +- `location` - _(Required)_ String representing one of the Google's gar locations |
| 233 | +- `keyfile` - _(Required)_ String representing service account json file contents |
| 234 | +- `repository_prefix` - _(Optional)_ String. See the [docs](https://codefresh.io/docs/docs/integrations/docker-registries/#using-an-optional-repository-prefix). |
| 235 | + |
| 236 | +--- |
| 237 | + |
| 238 | +`ecr` supports the following: |
| 239 | + |
| 240 | +- `region` - _(Required)_ String representing one of the Amazon regions |
| 241 | +- `access_key_id` - _(Required)_ String representing access key id |
| 242 | +- `secret_access_key` - _(Required)_ String representing secret access key |
| 243 | +- `repository_prefix` - _(Optional)_ String. See the [docs](https://codefresh.io/docs/docs/integrations/docker-registries/#using-an-optional-repository-prefix). |
| 244 | + |
| 245 | +--- |
| 246 | + |
| 247 | +`bintray` supports the following: |
| 248 | + |
| 249 | +- `domain` - _(Required)_ String representing the bintray domain |
| 250 | +- `username` - _(Required)_ String representing the username |
| 251 | +- `token` - _(Required)_ String representing token |
| 252 | +- `repository_prefix` - _(Optional)_ String. See the [docs](https://codefresh.io/docs/docs/integrations/docker-registries/#using-an-optional-repository-prefix). |
| 253 | + |
| 254 | +--- |
| 255 | + |
| 256 | +`other` supports the following: |
| 257 | + |
| 258 | +- `domain` - _(Required)_ String representing the bintray domain |
| 259 | +- `username` - _(Required)_ String representing the username |
| 260 | +- `password` - _(Required)_ String representing token |
| 261 | +- `repository_prefix` - _(Optional)_ String. See the [docs](https://codefresh.io/docs/docs/integrations/docker-registries/#using-an-optional-repository-prefix). |
| 262 | +- `behind_firewall` - _(Optional, Default = false)_ Bool. See the [docs](https://codefresh.io/docs/docs/administration/behind-the-firewall/#accessing-an-internal-docker-registry). |
| 263 | + |
| 264 | +--- |
0 commit comments