Skip to content

Commit 293f2bf

Browse files
authored
Use images published to MCR (#143)
1 parent a838e14 commit 293f2bf

File tree

10 files changed

+72
-63
lines changed

10 files changed

+72
-63
lines changed

.github/workflows/pr-ci.yml

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -282,27 +282,6 @@ jobs:
282282
set -euo pipefail
283283
make -s integration-test-no-up
284284
285-
publish-official-images:
286-
needs:
287-
- test-azure-needs-hosted-runner
288-
runs-on: ${{ fromJson(needs.test-azure-needs-hosted-runner.outputs.AZURE_RUNS_ON_JSON)}}
289-
defaults:
290-
run:
291-
shell: bash
292-
steps:
293-
- name: Checkout
294-
uses: actions/checkout@v3
295-
with:
296-
fetch-depth: 0
297-
298-
- name: Log in to Azure
299-
uses: ./.github/actions/login-azure
300-
301-
- name: Publish official images
302-
run: |
303-
set -euo pipefail
304-
make publish-official-images
305-
306285
build-windows-binaries:
307286
runs-on: ubuntu-latest
308287
defaults:
@@ -539,8 +518,10 @@ jobs:
539518
- name: get container registry
540519
run: |
541520
set -euo pipefail
542-
official_container_registry=$(echo "$DEVELOPER_CONFIG_BASE64" | base64 -d | jq -r '.officialContainerRegistry.fqdn')
543-
echo "OFFICIAL_CONTAINER_REGISTRY=$(echo $official_container_registry)" >> $GITHUB_ENV
521+
official_pull_container_registry=$(echo "$DEVELOPER_CONFIG_BASE64" | base64 -d | jq -r '.officialPullContainerRegistry.fqdn')
522+
echo "OFFICIAL_PULL_CONTAINER_REGISTRY=$(echo $official_pull_container_registry)" >> $GITHUB_ENV
523+
official_pull_container_registry_directory=$(echo "$DEVELOPER_CONFIG_BASE64" | base64 -d | jq -r '.officialPullContainerRegistry.directory // ""')
524+
echo "OFFICIAL_PULL_CONTAINER_REGISTRY_DIRECTORY=$(echo $official_pull_container_registry_directory)" >> $GITHUB_ENV
544525
545526
- name: Run GoReleaser
546527
uses: goreleaser/goreleaser-action@v5

Makefile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ _docker-build:
6767
target_arg="--${DOCKER_BUILD_TARGET}"
6868

6969
tag=$${EXPLICIT_IMAGE_TAG:-dev}
70+
dev_config=$$(scripts/get-config.sh --dev -o json)
7071

71-
registry=$$(scripts/get-config.sh --dev -e .wipContainerRegistry.fqdn)
72-
scripts/build-images.sh $$target_arg ${DOCKER_BUILD_ARCH_FLAGS} ${DOCKER_BUILD_PUSH_FLAGS} --tag "$$tag" --registry "$${registry}"
72+
registry=$$(echo "$${dev_config}" | jq -r '.wipContainerRegistry.fqdn')
73+
directory=$$(echo "$${dev_config}" | jq -r '.wipContainerRegistry.directory // ""')
74+
scripts/build-images.sh $$target_arg ${DOCKER_BUILD_ARCH_FLAGS} ${DOCKER_BUILD_PUSH_FLAGS} --tag "$$tag" --registry "$${registry}" --registry-directory "$${directory}"
7375

7476
docker-build-test: login-wip-acr
7577
$(MAKE) _docker-build DOCKER_BUILD_TARGET=test-connectivity
@@ -86,11 +88,13 @@ docker-build-worker-waiter: login-wip-acr
8688
docker-build: docker-build-test docker-build-tyger-server docker-build-buffer-sidecar docker-build-worker-waiter
8789

8890
publish-official-images:
89-
registry=$$(scripts/get-config.sh --dev -e .officialContainerRegistry.fqdn)
91+
dev_config=$$(scripts/get-config.sh --dev -o json)
92+
registry=$$(echo "$${dev_config}" | jq -r '.officialPushContainerRegistry.fqdn')
9093
registry_name=$$(echo "$$registry" | cut -d'.' -f1)
9194
az acr login --name "$${registry_name}"
95+
registry_directory=$$(echo "$${dev_config}" | jq -r '.officialPushContainerRegistry.directory // ""')
9296
tag=$$(git describe --tags)
93-
scripts/build-images.sh --push --push-force --arch amd64 --arch arm64 --tyger-server --worker-waiter --buffer-sidecar --helm --tag "$${tag}" --registry "$${registry}"
97+
scripts/build-images.sh --push --push-force --arch amd64 --arch arm64 --tyger-server --worker-waiter --buffer-sidecar --helm --tag "$${tag}" --registry "$${registry}" --registry-directory "$${registry_directory}"
9498

9599
integration-test-no-up-prereqs:
96100

@@ -119,13 +123,13 @@ get-tyger-uri:
119123
echo ${TYGER_URI}
120124

121125
install-cli:
122-
official_container_registry=$$(scripts/get-config.sh --dev -e .officialContainerRegistry.fqdn)
126+
dev_config=$$(scripts/get-config.sh --dev -o json)
127+
container_registry=$$(echo "$${dev_config}" | jq -r '.wipContainerRegistry.fqdn')
128+
container_registry_directory=$$(echo "$${dev_config}" | jq -r '.wipContainerRegistry.directory // ""')
123129
cd cli
124130
tag=$$(git describe --tags 2> /dev/null || echo "0.0.0")
125131
CGO_ENABLED=0 go install -buildvcs=false -ldflags="-s -w \
126-
-X main.version=$${tag} \
127-
-X github.com/microsoft/tyger/cli/internal/install.ContainerRegistry=$${official_container_registry} \
128-
-X github.com/microsoft/tyger/cli/internal/install.ContainerImageTag=$${tag}" \
132+
-X main.version=$${tag}" \
129133
./cmd/tyger ./cmd/buffer-sidecar ./cmd/tyger-proxy
130134

131135
cli-ready: install-cli

cli/.goreleaser.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ builds:
1111
ldflags:
1212
- -s -w
1313
- -X main.version={{ .Tag }}
14-
- -X github.com/microsoft/tyger/cli/internal/install.ContainerRegistry={{ .Env.OFFICIAL_CONTAINER_REGISTRY }}
14+
- -X github.com/microsoft/tyger/cli/internal/install.ContainerRegistry={{ .Env.OFFICIAL_PULL_CONTAINER_REGISTRY }}
15+
- -X github.com/microsoft/tyger/cli/internal/install.ContainerRegistryDirectory={{ .Env.OFFICIAL_PULL_CONTAINER_REGISTRY_DIRECTORY }}
1516
- -X github.com/microsoft/tyger/cli/internal/install.ContainerImageTag={{ .Tag }}
1617
goos:
1718
- linux

cli/internal/install/cloudinstall/config.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ api:
111111
# tyger:
112112
# repoName:
113113
# repoUrl: # not set if using `chartRef`
114-
# chartRef: # e.g. oci://tyger.azurecr.io/helm/tyger
114+
# chartRef: # e.g. oci://mcr.microsoft.com/tyger/helm/tyger
115115
# namespace:
116116
# version:
117117
# values:

cli/internal/install/cloudinstall/helm.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,6 @@ func (inst *Installer) InstallTyger(ctx context.Context) error {
321321
}
322322

323323
func (inst *Installer) InstallTygerHelmChart(ctx context.Context, restConfig *rest.Config, dryRun bool) (manifest string, valuesYaml string, err error) {
324-
if install.ContainerRegistry == "" {
325-
panic("officialContainerRegistry not set during build")
326-
}
327-
328-
if install.ContainerImageTag == "" {
329-
panic("officialContainerImageTag not set during build")
330-
}
331-
332324
clustersConfigJson, err := json.Marshal(inst.Config.Cloud.Compute.Clusters)
333325
if err != nil {
334326
return "", "", fmt.Errorf("failed to marshal cluster configuration: %w", err)
@@ -412,13 +404,13 @@ func (inst *Installer) InstallTygerHelmChart(ctx context.Context, restConfig *re
412404
helmConfig := HelmChartConfig{
413405
Namespace: TygerNamespace,
414406
ReleaseName: DefaultTygerReleaseName,
415-
ChartRef: fmt.Sprintf("oci://%s/helm/tyger", install.ContainerRegistry),
407+
ChartRef: fmt.Sprintf("oci://%s%shelm/tyger", install.ContainerRegistry, install.GetNormalizedContainerRegistryDirectory()),
416408
Version: install.ContainerImageTag,
417409
Values: map[string]any{
418-
"image": fmt.Sprintf("%s/tyger-server:%s", install.ContainerRegistry, install.ContainerImageTag),
419-
"bufferSidecarImage": fmt.Sprintf("%s/buffer-sidecar:%s", install.ContainerRegistry, install.ContainerImageTag),
420-
"bufferCopierImage": fmt.Sprintf("%s/buffer-copier:%s", install.ContainerRegistry, install.ContainerImageTag),
421-
"workerWaiterImage": fmt.Sprintf("%s/worker-waiter:%s", install.ContainerRegistry, install.ContainerImageTag),
410+
"image": fmt.Sprintf("%s%styger-server:%s", install.ContainerRegistry, install.GetNormalizedContainerRegistryDirectory(), install.ContainerImageTag),
411+
"bufferSidecarImage": fmt.Sprintf("%s%sbuffer-sidecar:%s", install.ContainerRegistry, install.GetNormalizedContainerRegistryDirectory(), install.ContainerImageTag),
412+
"bufferCopierImage": fmt.Sprintf("%s%sbuffer-copier:%s", install.ContainerRegistry, install.GetNormalizedContainerRegistryDirectory(), install.ContainerImageTag),
413+
"workerWaiterImage": fmt.Sprintf("%s%sworker-waiter:%s", install.ContainerRegistry, install.GetNormalizedContainerRegistryDirectory(), install.ContainerImageTag),
422414
"hostname": inst.Config.Api.DomainName,
423415
"identity": map[string]any{
424416
"tygerServer": map[string]any{

cli/internal/install/dockerinstall/validation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func (inst *Installer) QuickValidateConfig() bool {
154154
}
155155

156156
func defaultImage(repo string) string {
157-
return fmt.Sprintf("%s/%s:%s", install.ContainerRegistry, repo, install.ContainerImageTag)
157+
return fmt.Sprintf("%s%s%s:%s", install.ContainerRegistry, install.GetNormalizedContainerRegistryDirectory(), repo, install.ContainerImageTag)
158158
}
159159

160160
func validationError(success *bool, format string, args ...any) {

cli/internal/install/installer.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"context"
88
"errors"
99
"io"
10+
"strings"
11+
"sync"
1012
)
1113

1214
var (
@@ -15,11 +17,21 @@ var (
1517
)
1618

1719
var (
18-
// Set during build but we provide defaults so that there is some value when debugging.
19-
// We will need to update these from time to time. Alternatively, you can set the registry
20-
// values using the --set command-line argument.
21-
ContainerRegistry string = "tyger.azurecr.io"
22-
ContainerImageTag string = "v0.4.0-112-g428a5e8"
20+
// Set during build
21+
ContainerRegistry string = ""
22+
ContainerRegistryDirectory string = ""
23+
ContainerImageTag string = ""
24+
25+
GetNormalizedContainerRegistryDirectory = sync.OnceValue(func() string {
26+
normalized := ContainerRegistryDirectory
27+
if !strings.HasPrefix(normalized, "/") {
28+
normalized = "/" + normalized
29+
}
30+
if !strings.HasSuffix(normalized, "/") {
31+
normalized = normalized + "/"
32+
}
33+
return normalized
34+
})
2335
)
2436

2537
type Installer interface {

deploy/config/microsoft/devconfig.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
subscriptionId: 87d8acb3-5176-4651-b457-6ab9cefd8e3d
22
wipContainerRegistry:
3-
name: eminence
43
fqdn: eminence.azurecr.io
5-
officialContainerRegistry:
6-
name: tyger
7-
fqdn: tyger.azurecr.io
4+
officialPushContainerRegistry:
5+
fqdn: tygerprod.azurecr.io
6+
directory: /public/tyger
7+
officialPullContainerRegistry:
8+
fqdn: mcr.microsoft.com
9+
directory: /tyger
810
keyVault: eminence
911
testAppUri: api://tyger-test-client
1012
pemCertSecret:

docs/introduction/installation/cloud-installation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ api:
157157
# tyger:
158158
# repoName:
159159
# repoUrl: # not set if using `chartRef`
160-
# chartRef: # e.g. oci://tyger.azurecr.io/helm/tyger
160+
# chartRef: # e.g. oci://mcr.microsoft.com/tyger/helm/tyger
161161
# namespace:
162162
# version:
163163
# values: # Helm values overrides
@@ -175,7 +175,7 @@ command-line with `--set`. For example:
175175

176176
```bash
177177
tyger api install -f config.yml \
178-
--set api.helm.tyger.chartRef=oci://tyger.azurecr.io/helm/tyger \
178+
--set api.helm.tyger.chartRef=oci://mcr.microsoft.com/tyger/helm/tyger \
179179
--set api.helm.tyger.version=v0.4.0
180180
```
181181

@@ -216,7 +216,7 @@ tyger api install -f config.yml
216216
```
217217

218218
This command installs the Tyger API from the Helm chart in the
219-
`tyger.azurecr.io/helm/tyger` registry, using a version baked into the `tyger`
219+
`mcr.microsoft.com/tyger/helm/tyger` registry, using a version baked into the `tyger`
220220
CLI. Upgrade the server by updating the CLI and rerunning `tyger api install`.
221221

222222
The API's TLS certificate is automatically created using [Let's

scripts/build-images.sh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Options:
1919
--worker-waiter Build (and optionally push) the worker-waiter image
2020
--buffer-sidecar Build (and optionally push) the buffer-sidecar image
2121
--helm Package and push the Tyger Helm chart
22+
--registry-directory The parent directory of the repositories. e.g. <registry>/<registry-dir>/<repo-name>
2223
--arch amd64|arm64 The architecture to build for. Can be specified multiple times.
2324
--push Push runtime images (requires --tag or --use-git-hash-as-tag)
2425
--push-force Force runtime images, will overwrite images with same tag (requires --tag or --use-git-hash-as-tag)
@@ -28,6 +29,8 @@ Options:
2829
EOF
2930
}
3031

32+
registry_dir="/"
33+
3134
while [[ $# -gt 0 ]]; do
3235
key="$1"
3336

@@ -71,6 +74,10 @@ while [[ $# -gt 0 ]]; do
7174
push=1
7275
shift
7376
;;
77+
--registry-directory)
78+
registry_dir="$2"
79+
shift 2
80+
;;
7481
--push-force)
7582
push=1
7683
force=1
@@ -96,6 +103,16 @@ while [[ $# -gt 0 ]]; do
96103
esac
97104
done
98105

106+
# Ensure registry_dir starts with a /
107+
if [[ ! "$registry_dir" =~ ^/ ]]; then
108+
registry_dir="/$registry_dir"
109+
fi
110+
111+
# Ensure registry_dir ends with a /
112+
if [[ ! "$registry_dir" =~ /$ ]]; then
113+
registry_dir="$registry_dir/"
114+
fi
115+
99116
# if nether amd64 nor arm64 is specified, build for both
100117
if [[ -z "${amd64:-}" && -z "${arm64:-}" ]]; then
101118
amd64=true
@@ -107,7 +124,7 @@ export DOCKER_BUILDKIT=1
107124
repo_root_dir="$(dirname "$0")/.."
108125

109126
function build_and_push_platform() {
110-
full_image="${container_registry_fqdn}/${repo}:${image_tag_with_platform}"
127+
full_image="${container_registry_fqdn}${registry_dir}${repo}:${image_tag_with_platform}"
111128
echo "Building image ${full_image}..."
112129

113130
set +e
@@ -156,8 +173,8 @@ function build_and_push() {
156173
return 0
157174
fi
158175

159-
manifest_name="${container_registry_fqdn}/${repo}:${image_tag}"
160-
docker manifest create --amend "${manifest_name}" "${container_registry_fqdn}/${repo}:${image_tag}-amd64" "${container_registry_fqdn}/${repo}:${image_tag}-arm64" >/dev/null
176+
manifest_name="${container_registry_fqdn}${registry_dir}${repo}:${image_tag}"
177+
docker manifest create --amend "${manifest_name}" "${container_registry_fqdn}${registry_dir}${repo}:${image_tag}-amd64" "${container_registry_fqdn}${registry_dir}${repo}:${image_tag}-arm64" >/dev/null
161178

162179
# Push manigest
163180
if [[ -z "${force:-}" ]]; then
@@ -232,7 +249,7 @@ if [[ -n "${helm:-}" ]]; then
232249
username="00000000-0000-0000-0000-000000000000"
233250
echo "${token}" | docker login "${container_registry_fqdn}" -u "${username}" --password-stdin
234251

235-
helm_repo_namespace="oci://${container_registry_fqdn}/helm"
252+
helm_repo_namespace="oci://${container_registry_fqdn}${registry_dir}helm"
236253
chart_dir=${repo_root_dir}/deploy/helm/tyger
237254
package_dir=$(mktemp -d)
238255

0 commit comments

Comments
 (0)