|
| 1 | +[id="stage-1-build-and-package-a-devfile-registry_{context}"] |
| 2 | +== Stage 1: Build and Package a Devfile Registry |
| 3 | + |
| 4 | +The main goal of this stage is: |
| 5 | + |
| 6 | +. Pull in resources into the registry as part of the registry build. |
| 7 | +. Modify the devfile to update references to those offline resources as part of the registry build. |
| 8 | + |
| 9 | +.Prerequisites |
| 10 | + |
| 11 | +* Golang 1.17.x or higher |
| 12 | +* Docker 17.05 or higher or Podman 4.0.x or higher |
| 13 | +* Git |
| 14 | +* Curl |
| 15 | +* Archive Tools (such as `unzip`) |
| 16 | + |
| 17 | +=== Create Offline Registry |
| 18 | + |
| 19 | +Download / clone the link:https://github.com/devfile/registry[devfile/registry] repository. |
| 20 | + |
| 21 | +.Procedure |
| 22 | + |
| 23 | +* Clone through HTTPS |
| 24 | ++ |
| 25 | +[source,bash] |
| 26 | +---- |
| 27 | +git clone https://github.com/devfile/registry.git /path/to/registry |
| 28 | +---- |
| 29 | ++ |
| 30 | +* Clone through SSH |
| 31 | ++ |
| 32 | +[source,bash] |
| 33 | +---- |
| 34 | +git clone [email protected]:devfile/registry.git /path/to/registry |
| 35 | +---- |
| 36 | + |
| 37 | +.Additional resources |
| 38 | + |
| 39 | +* To create your own registry Git repository, see xref:building-a-custom-devfile-registry.adoc[Building a custom devfile registry] |
| 40 | + |
| 41 | +=== Install Stack Images |
| 42 | + |
| 43 | +You will first need to collect all the image tags used in the stacks needed for offline access. The image tags collected are to each be pulled, re-tagged, and installed into the image repository accessible by the offline cluster. Procedure here will require you to **change the devfile**. |
| 44 | + |
| 45 | +.Procedure |
| 46 | +. Use the `docker pull` or the `podman pull` to pull down an image for a stack component: |
| 47 | ++ |
| 48 | +[source,bash] |
| 49 | +---- |
| 50 | +podman pull registry.access.redhat.com/ubi8/nodejs-16:latest |
| 51 | +---- |
| 52 | ++ |
| 53 | +. Use the `docker tag` or the `podman tag` to re-tag the image that uses the form `<registry_host>:<port>/<project>/<image>`: |
| 54 | ++ |
| 55 | +[source,bash] |
| 56 | +---- |
| 57 | +podman tag registry.access.redhat.com/ubi8/nodejs-16:latest \ |
| 58 | + <registry_host>:<port>/<project>/nodejs-16:latest |
| 59 | +---- |
| 60 | ++ |
| 61 | +. Use the `docker push` or `podman push` to push the re-tagged image to the image repository at `<registry_host>:<port>`: |
| 62 | ++ |
| 63 | +[source,bash] |
| 64 | +---- |
| 65 | +podman push <registry_host>:<port>/<project>/nodejs-16:latest |
| 66 | +---- |
| 67 | + |
| 68 | +.Additional resources |
| 69 | + |
| 70 | +* For more on interacting with the OpenShift Image Registry, see link:https://docs.openshift.com/container-platform/4.10/registry/accessing-the-registry.html[Accessing the registry] |
| 71 | + |
| 72 | +=== Packaging Starter Projects |
| 73 | + |
| 74 | +To package starter projects you will need to download them manually then place them under `/stacks/<stack>/<zip>-offline.zip`. Procedure here will require you to **change the devfile**. |
| 75 | + |
| 76 | +*Note*: Starter projects must be packaged under an archive with the suffix `-offline` to be pulled into the registry. |
| 77 | + |
| 78 | +.Procedure |
| 79 | + |
| 80 | +. `zip` - Download archive |
| 81 | ++ |
| 82 | +Example |
| 83 | ++ |
| 84 | +[source,bash] |
| 85 | +---- |
| 86 | +cd /path/to/registry |
| 87 | +curl -L https://code.quarkus.io/d?e=io.quarkus%3Aquarkus-resteasy&e=io.quarkus%3Aquarkus-micrometer&e=io.quarkus%3Aquarkus-smallrye-health&e=io.quarkus%3Aquarkus-openshift&cn=devfile \ |
| 88 | + -o stacks/java-quarkus/community-offline.zip |
| 89 | +---- |
| 90 | ++ |
| 91 | +. `git` - Package cloned contents into a directory then archive |
| 92 | ++ |
| 93 | +Example |
| 94 | ++ |
| 95 | +[source,bash] |
| 96 | +---- |
| 97 | +cd /path/to/registry |
| 98 | +git clone https://github.com/odo-devfiles/nodejs-ex.git \ |
| 99 | + stacks/nodejs/nodejs-starter-offline |
| 100 | +cd stacks/nodejs |
| 101 | +zip -r nodejs-starter-offline.zip nodejs-starter-offline |
| 102 | +---- |
| 103 | + |
| 104 | +=== Modify Devfile |
| 105 | + |
| 106 | +Change the devfile so you can update references to those offline resources as part of the registry build. For all the items pulled into the registry, update the corresponding devfile entries to reference the resources within the offline version in the registry: |
| 107 | + |
| 108 | +. All location references to `starterProjects` will change to local paths relative to the stacks directory. |
| 109 | +. Stack component image references will change to use the offline accessible image repository. |
| 110 | + |
| 111 | +.Procedure |
| 112 | + |
| 113 | +. Under `starterProjects`, find the starter project definition you want to make offline. |
| 114 | +. Under the definition for the starter project find either `git` or `zip`: |
| 115 | ++ |
| 116 | +.Starter Project Before |
| 117 | +==== |
| 118 | +---- |
| 119 | +... |
| 120 | +starterProjects: |
| 121 | + - name: nodejs-starter |
| 122 | + git: |
| 123 | + remotes: |
| 124 | + origin: https://github.com/odo-devfiles/nodejs-ex.git |
| 125 | +... |
| 126 | +---- |
| 127 | +==== |
| 128 | ++ |
| 129 | +. Do one of the following depending on the block type: |
| 130 | + * If `git`, replace all of the `git` block with a `zip` block and add the `location` to be the path to the local file under the stack root directory (`<registry_root>/stacks/<stack>/`). |
| 131 | + * If `zip`, just replace the value of `location` to the local file under the stack root directory (`<registry_root>/stacks/<stack>/`). |
| 132 | + |
| 133 | +.Verification step |
| 134 | + |
| 135 | +To confirm you modified your devfile, verify your altered starter project definition is similar to the following example: |
| 136 | + |
| 137 | +.Altered Starter Project Definition |
| 138 | +==== |
| 139 | +---- |
| 140 | +... |
| 141 | +starterProjects: |
| 142 | + - name: nodejs-starter |
| 143 | + zip: |
| 144 | + location: nodejs-starter-offline.zip |
| 145 | +... |
| 146 | +---- |
| 147 | +==== |
| 148 | + |
| 149 | +.Additional resources |
| 150 | + |
| 151 | +* To learn more about starter projects in devfiles, see xref:adding-projects-to-a-devfile.adoc[Adding projects to a devfile] |
| 152 | + |
| 153 | +=== Build Registry |
| 154 | + |
| 155 | +.Procedure |
| 156 | + |
| 157 | +. If not already at the root of the registry, change to the root of the registry. |
| 158 | ++ |
| 159 | +[source,bash] |
| 160 | +---- |
| 161 | +cd /path/to/registry |
| 162 | +---- |
| 163 | ++ |
| 164 | +. Build the registry image. |
| 165 | ++ |
| 166 | +[source,bash] |
| 167 | +---- |
| 168 | +bash .ci/build.sh |
| 169 | +---- |
| 170 | + |
| 171 | +.Additional resources |
| 172 | + |
| 173 | +* For more information about building your own registry image, see xref:building-a-custom-devfile-registry.adoc[Building a custom devfile registry] |
0 commit comments