|
1 | 1 | parameters: |
2 | 2 | - name: arch |
3 | 3 | type: string |
4 | | - values: |
5 | | - - amd64 |
6 | | - - arm64 |
7 | 4 |
|
8 | 5 | - name: os |
9 | 6 | type: string |
10 | | - values: |
11 | | - - windows |
12 | | - - linux |
13 | 7 |
|
14 | 8 | - name: images |
15 | 9 | type: object |
16 | 10 |
|
17 | 11 |
|
18 | 12 | jobs: |
19 | | -- ${{ each image in parameters.images }}: |
20 | | - - job: ${{ replace(image, '-', '_') }}_${{ parameters.os }}_${{ parameters.arch }} |
21 | | - displayName: Build Images |
22 | | - # pool: |
23 | | - # arch: ${{ parameters.arch }} |
24 | | - # os: ${{ parameters.os }} |
25 | | - # ${{ if eq(parameters.os, 'windows') }}: |
26 | | - # name: $(BUILD_POOL_NAME_DEFAULT_WINDOWS) |
27 | | - # ${{ elseif eq(parameters.os, 'linux') }}: |
28 | | - # ${{ if eq(parameters.arch, 'amd64') }}: |
29 | | - # name: $(BUILD_POOL_NAME_DEFAULT) |
30 | | - # ${{ elseif eq(parameters.arch, 'arm64') }}: |
31 | | - # name: $(BUILD_POOL_NAME_LINUX_ARM64) |
32 | | - templateContext: |
33 | | - authenticatedContainerRegistries: |
34 | | - - serviceConnection: 'Azure Container Networking - ACN Public Registry - Retina' |
35 | | - - registry: onebranch.azurecr.io |
36 | | - tenant: AME |
37 | | - identity: 1ESPipelineIdentity |
38 | | - containers: |
39 | | - ${{ if eq(parameters.os, 'windows') }}: |
40 | | - default_windows_container: |
41 | | - image: onebranch.azurecr.io/windows/ltsc2019/vse2022:latest |
42 | | - ${{ elseif eq(parameters.os, 'linux') }}: |
43 | | - default_linux_container: |
44 | | - image: onebranch.azurecr.io/linux/ubuntu-2204:latest |
45 | | - outputs: |
46 | | - - output: pipelineArtifact |
47 | | - targetPath: $(System.DefaultWorkingDirectory)/output |
48 | | - artifactName: output |
49 | | - type: containerBuildJob |
50 | | - arguments: |
51 | | - pipelineArtifact: output |
52 | | - image: $(IMAGE_NAME_AND_TAG_${{ parameters.name }}) |
53 | | - dockerfile: $(DOCKERFILE_PATH_${{ parameters.name }}) |
54 | | - path: $(BUILD_CONTEXT_${{ parameters.name }}) |
55 | | - buildArguments: TARGET=${{ parameters.os }} OS=${{ parameters.os }} PLATFORM=${{ parameters.os }} ARCH=${{ parameters.arch }} $(EXTRA_BUILD_ARGS_${{ parameters.name }}) |
56 | | - enableNetwork: true # Optional. Default: false |
57 | | - enablePull: false # Optional. Default: true |
58 | | - enableCache: true # Optional. Default: false |
59 | | - useBuildKit: true |
60 | | - |
| 13 | +- ${{ each image in split(parameters.images, '\n') }}: |
| 14 | + - job: ${{ image }}_${{ parameters.os }}_${{ parameters.arch }} |
| 15 | + displayName: Build Image - (${{ image }} ${{ parameters.os }}/${{ parameters.arch }}) |
| 16 | + |
61 | 17 | steps: |
62 | | - - task: GoTool@0 |
63 | | - inputs: |
64 | | - version: $(GO_VERSION) |
65 | | - - bash: | |
66 | | - set -e |
67 | | - |
68 | | - BUILD_CONTEXT=$(make "$MAKE_BUILD_CONTEXT") |
69 | | - echo >&2 "##vso[task.setvariable variable=BUILD_CONTEXT_${VAR_ID};]$BUILD_CONTEXT" |
70 | | - |
71 | | - IMAGE_NAME_AND_TAG=$(make "$MAKE_IMG_NAME_AND_TAG") |
72 | | - echo >&2 "##vso[task.setvariable variable=IMAGE_NAME_AND_TAG_${VAR_ID};]$IMAGE_NAME_AND_TAG" |
73 | | - |
74 | | - DOCKERFILE_PATH=$(make "$MAKE_DOCKERFILE_PATH") |
75 | | - echo >&2 "##vso[task.setvariable variable=DOCKERFILE_PATH_${VAR_ID};]$DOCKERFILE_PATH" |
76 | | - |
77 | | - EXTRA_BUILD_ARGS=$(make "$MAKE_EXTRA_BUILD_ARGS") |
78 | | - echo >&2 "##vso[task.setvariable variable=EXTRA_BUILD_ARGS_${VAR_ID};]$EXTRA_BUILD_ARGS" |
79 | | - displayName: "Get Image Name" |
80 | | - env: |
81 | | - VAR_ID: ${{ parameters.name }} |
82 | | - MAKE_BUILD_CONTEXT: ${{ parameters.name }}-image-build-context |
83 | | - MAKE_IMG_NAME_AND_TAG: ${{ parameters.name }}-image-name-and-tag |
84 | | - MAKE_DOCKERFILE_PATH: ${{ parameters.name }}-image-dockerfile-path |
85 | | - MAKE_EXTRA_BUILD_ARGS: ${{ parameters.name }}-image-build-args |
| 18 | + - task: GoTool@0 |
| 19 | + inputs: |
| 20 | + version: $(GO_VERSION) |
| 21 | + |
| 22 | + - bash: | |
| 23 | + set -e |
| 24 | + |
| 25 | + BUILD_CONTEXT=$(make "$MAKE_BUILD_CONTEXT") |
| 26 | + echo >&2 "##vso[task.setvariable variable=BUILD_CONTEXT_${VAR_ID};]$BUILD_CONTEXT" |
| 27 | + |
| 28 | + IMAGE_NAME_AND_TAG=$(make "$MAKE_IMG_NAME_AND_TAG") |
| 29 | + echo >&2 "##vso[task.setvariable variable=IMAGE_NAME_AND_TAG_${VAR_ID};]$IMAGE_NAME_AND_TAG" |
| 30 | + |
| 31 | + DOCKERFILE_PATH=$(make "$MAKE_DOCKERFILE_PATH") |
| 32 | + echo >&2 "##vso[task.setvariable variable=DOCKERFILE_PATH_${VAR_ID};]$DOCKERFILE_PATH" |
| 33 | + |
| 34 | + EXTRA_BUILD_ARGS=$(make "$MAKE_EXTRA_BUILD_ARGS") |
| 35 | + echo >&2 "##vso[task.setvariable variable=EXTRA_BUILD_ARGS_${VAR_ID};]$EXTRA_BUILD_ARGS" |
| 36 | + displayName: "Get Image Name" |
| 37 | + env: |
| 38 | + VAR_ID: ${{ parameters.name }} |
| 39 | + MAKE_BUILD_CONTEXT: ${{ parameters.name }}-image-build-context |
| 40 | + MAKE_IMG_NAME_AND_TAG: ${{ parameters.name }}-image-name-and-tag |
| 41 | + MAKE_DOCKERFILE_PATH: ${{ parameters.name }}-image-dockerfile-path |
| 42 | + MAKE_EXTRA_BUILD_ARGS: ${{ parameters.name }}-image-build-args |
| 43 | +
|
| 44 | + - template: containers/container-template.steps.yaml |
| 45 | + parameters: |
| 46 | + arch: ${{ parameters.arch }} |
| 47 | + name: ${{ parameters.name }} |
| 48 | + os: ${{ parameters.os }} |
0 commit comments