|
| 1 | +# Using an OCI context |
| 2 | + |
| 3 | +The sample below builds a windows image based on an OCI context. |
| 4 | + |
| 5 | +> These are `powershell` commands. |
| 6 | +
|
| 7 | +## Bundle up the context into an OCI Artifact |
| 8 | + |
| 9 | +The context has a simple `Dockerfile` and a `hello.txt` |
| 10 | +Use oras to create the context and ensure you are in `context` directory. |
| 11 | + |
| 12 | +```shell |
| 13 | +$REGISTRY="myregistry" |
| 14 | +$REGISTRY_LOGIN_SERVER="myregistry.azurecr.io" |
| 15 | +cd context |
| 16 | +az acr login -n $REGISTRY |
| 17 | +oras push $REGISTRY_LOGIN_SERVER/windows/oci-context:latest . |
| 18 | +``` |
| 19 | + |
| 20 | +## Create an ACR to use the context |
| 21 | + |
| 22 | +Create a base image trigger enabled task with the new context and ensure that you specify the required `--platform`. |
| 23 | + |
| 24 | +```powershell |
| 25 | +$REGISTRY="myregistry" |
| 26 | +$REGISTRY_LOGIN_SERVER="myregistry.azurecr.io" |
| 27 | +az acr task create ` |
| 28 | + --registry $REGISTRY ` |
| 29 | + --name ocicontextbuild ` |
| 30 | + --platform Windows/amd64 ` |
| 31 | + --image "windowsimage:{{.Run.ID}}" ` |
| 32 | + --context "oci://$REGISTRY_LOGIN_SERVER/windows/oci-context:latest" ` |
| 33 | + --file Dockerfile ` |
| 34 | + --commit-trigger-enabled false ` |
| 35 | + --base-image-trigger-enabled true |
| 36 | +``` |
| 37 | + |
| 38 | +## Run the task to build and register the base image |
| 39 | + |
| 40 | +Execute the task to build the container image. |
| 41 | + |
| 42 | +```powershell |
| 43 | +$REGISTRY="myregistry" |
| 44 | +az acr task run --name ocicontextbuild --registry $REGISTRY |
| 45 | +``` |
| 46 | + |
| 47 | +The output should confirm that the base images were identified. |
| 48 | + |
| 49 | +``` |
| 50 | +... |
| 51 | +- image: |
| 52 | + registry: myregistry.azurecr.io |
| 53 | + repository: windowsimage |
| 54 | + tag: cf1bun |
| 55 | + digest: sha256:90f3c6534f9ed4ed8fa5bdaca006e284f0900bb19a850c0a249bede83bb6ed70 |
| 56 | + runtime-dependency: |
| 57 | + registry: mcr.microsoft.com |
| 58 | + repository: windows/servercore |
| 59 | + tag: ltsc2019 |
| 60 | + digest: sha256:2bacc4bdc5d1bd805587cb90a2fb2d58d1c775b02df1a19fd221cbfc639ff587 |
| 61 | + git: {} |
| 62 | +
|
| 63 | +
|
| 64 | +Run ID: cf1bun was successful after 5m1s |
| 65 | +``` |
0 commit comments