|
| 1 | +parameters: |
| 2 | +- name: supportedPlatforms |
| 3 | + type: jobList |
| 4 | + default: [] |
| 5 | + |
| 6 | +- name: targetOs |
| 7 | + type: string |
| 8 | + |
| 9 | +- name: targetArch |
| 10 | + type: string |
| 11 | + |
| 12 | + |
| 13 | +jobs: |
| 14 | +- ${{ each supportedPlatformJob in parameters.supportedPlatforms }}: |
| 15 | + - ${{ each imageName in supportedPlatformJob.images }}: |
| 16 | + - job: ${{ replace(concat(imageName, '_', supportedPlatformJob.name), '-', '_') }} |
| 17 | + displayName: Build Image - (${{ imageName }} ${{ parameters.targetOs }}/${{ parameters.targetArch }}) |
| 18 | + steps: |
| 19 | + - checkout: self |
| 20 | + |
| 21 | + - task: GoTool@0 |
| 22 | + inputs: |
| 23 | + version: $(GO_VERSION) |
| 24 | + |
| 25 | + - bash: | |
| 26 | + set -e |
| 27 | + |
| 28 | + VAR_ID="${IMAGE}_${OS}_${ARCH}" |
| 29 | + |
| 30 | + BUILD_CONTEXT=$(make "$MAKE_BUILD_CONTEXT") |
| 31 | + echo >&2 "##vso[task.setvariable variable=BUILD_CONTEXT_${VAR_ID};]$BUILD_CONTEXT" |
| 32 | + |
| 33 | + IMAGE_PLATFORM_TAG=$(make "$MAKE_IMAGE_TAG") |
| 34 | + echo >&2 "##vso[task.setvariable variable=IMAGE_PLATFORM_TAG_${VAR_ID};]$IMAGE_PLATFORM_TAG" |
| 35 | + |
| 36 | + IMAGE_NAME_AND_TAG=$(make "$MAKE_IMAGE_NAME_AND_TAG") |
| 37 | + echo >&2 "##vso[task.setvariable variable=IMAGE_NAME_AND_TAG_${VAR_ID};]$IMAGE_NAME_AND_TAG" |
| 38 | + |
| 39 | + DOCKERFILE_PATH=$(make "$MAKE_DOCKERFILE_PATH") |
| 40 | + echo >&2 "##vso[task.setvariable variable=DOCKERFILE_PATH_${VAR_ID};]$DOCKERFILE_PATH" |
| 41 | + |
| 42 | + EXTRA_BUILD_ARGS=$(make "$MAKE_EXTRA_BUILD_ARGS") |
| 43 | + echo >&2 "##vso[task.setvariable variable=EXTRA_BUILD_ARGS_${VAR_ID};]$EXTRA_BUILD_ARGS" |
| 44 | + displayName: "Get Image Build Data" |
| 45 | + env: |
| 46 | + IMAGE: ${{ imageName }} |
| 47 | + OS: ${{ parameters.targetOs }} |
| 48 | + ARCH: ${{ parameters.targetArch }} |
| 49 | + PLATFORM: ${{ parameters.targetOs }}/${{ parameters.targetArch }} |
| 50 | + MAKE_IMAGE_TAG: ${{ imageName }}-image-tag |
| 51 | + MAKE_BUILD_CONTEXT: ${{ imageName }}-image-build-context |
| 52 | + MAKE_IMAGE_NAME_AND_TAG: ${{ imageName }}-image-name-and-tag |
| 53 | + MAKE_DOCKERFILE_PATH: ${{ imageName }}-dockerfile-path |
| 54 | + MAKE_EXTRA_BUILD_ARGS: ${{ imageName }}-docker-build-args |
| 55 | + |
| 56 | + - template: ./container-template.steps.yaml |
| 57 | + parameters: |
| 58 | + imageNameAndTag: $(IMAGE_NAME_AND_TAG_${{ imageName }}_${{ parameters.targetOs }}_${{ parameters.targetArch }}) |
| 59 | + dockerfilePath: $(DOCKERFILE_PATH_${{ imageName }}_${{ parameters.targetOs }}_${{ parameters.targetArch }}) |
| 60 | + buildContextPath: $(Build.SourcesDirectory) |
| 61 | + targetVersion: $(IMAGE_PLATFORM_TAG_${{ imageName }}_${{ parameters.targetOs }}_${{ parameters.targetArch }}) |
| 62 | + targetOs: ${{ parameters.targetOs }} |
| 63 | + targetArch: ${{ parameters.targetArch }} |
| 64 | + targetPlatform: "${{ parameters.targetOs }}/${{ parameters.targetArch }}" |
| 65 | + addBuildArgs: $(EXTRA_BUILD_ARGS_${{ imageName }}_${{ parameters.targetOs }}_${{ parameters.targetArch }}) |
| 66 | + buildOs: ${{ supportedPlatformJob.templatContext.buildOs }} |
| 67 | + buildArch: ${{ supportedPlatformJob.templateContext.buildArch }} |
| 68 | + buildPlatform: "${{ supportedPlatformJob.templatContext.buildOs }}/${{ supportedPlatformJob.templateContext.buildArch }}" |
0 commit comments