From 6e2620fad27644f3c2359a69c4e493d126605ac0 Mon Sep 17 00:00:00 2001 From: Wei Dong <40835867+dw511214992@users.noreply.github.com> Date: Wed, 1 Mar 2023 20:20:24 +0800 Subject: [PATCH] build docker ci (#5589) * docker ci * docker ci * docker ci * docker ci --- .../build-publish-docker-image.yml | 69 +++++++++++++++++++ .../documents/docker/build-docker-image.md | 6 +- 2 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 tools/sdk-generation-pipeline/build-publish-docker-image.yml diff --git a/tools/sdk-generation-pipeline/build-publish-docker-image.yml b/tools/sdk-generation-pipeline/build-publish-docker-image.yml new file mode 100644 index 00000000000..01821cc3f2c --- /dev/null +++ b/tools/sdk-generation-pipeline/build-publish-docker-image.yml @@ -0,0 +1,69 @@ +trigger: none + +pr: none + +parameters: + - name: dockerImage + displayName: Docker Image + type: string + default: sdkgeneration.azurecr.io/sdk-generation:beta-1.0 + - name: dockerContainerRegistry + displayName: Docker Container Registry + type: string + default: sdkgeneration.azurecr.io + +variables: + - template: ../../eng/pipelines/templates/variables/globals.yml + - name: NodeVersion + value: '16.x' + - name: VAR_ARTIFACT_NAME + value: 'packages' + - name: VAR_DOCKER_IMAGE_ARTIFACT_NAME + value: 'dockerImages' + - name: VAR_BUILD_ARTIFACT_STAGING_DIRECTORY + value: $(Build.ArtifactStagingDirectory) + +pool: + name: "azsdk-pool-mms-ubuntu-2004-general" + vmImage: "MMSUbuntu20.04" + +stages: + - stage: Build + jobs: + - job: Build + steps: + - task: NodeTool@0 + inputs: + versionSpec: '$(NodeVersion)' + displayName: 'Install Node.js' + + - bash: | + npm install -g @microsoft/rush + npm install -g typescript@4.6.2 + displayName: 'Install dependencies' + + - script: | + rush update + displayName: 'rush update' + workingDirectory: $(System.DefaultWorkingDirectory)/tools/sdk-generation-pipeline + + - script: | + rush build + displayName: 'rush build' + workingDirectory: $(System.DefaultWorkingDirectory)/tools/sdk-generation-pipeline + + - script: | + rushx pack + displayName: 'Pack @azure-tools/sdk-generation-cli' + workingDirectory: $(System.DefaultWorkingDirectory)/tools/sdk-generation-pipeline/packages/sdk-generation-cli + + - script: | + docker build -t ${{ parameters.dockerImage }} . + displayName: 'Build docker image' + workingDirectory: $(System.DefaultWorkingDirectory)/tools/sdk-generation-pipeline + + - script: | + docker login -u $(DockerUserName) -p $(DockerPassword) ${{ parameters.dockerContainerRegistry }} + docker push ${{ parameters.dockerImage }} + displayName: 'Publish docker image' + workingDirectory: $(System.DefaultWorkingDirectory)/tools/sdk-generation-pipeline diff --git a/tools/sdk-generation-pipeline/documents/docker/build-docker-image.md b/tools/sdk-generation-pipeline/documents/docker/build-docker-image.md index 9c310dae6e5..0462f5d9bc2 100644 --- a/tools/sdk-generation-pipeline/documents/docker/build-docker-image.md +++ b/tools/sdk-generation-pipeline/documents/docker/build-docker-image.md @@ -1,5 +1,4 @@ -If you want to rebuild the docker image, you only can do it in your local. It's suggested to create a release pipeline to build it. (Previously we find that sometimes it will be timeout because the pipeline costs much time in building and pushing docker image, but now the agent pool should be very fast.) - +## Rebuild docker In Local Steps to rebuild the docker image: 1. `cd tools/sdk-generation-pipeline` 2. `rush update` @@ -8,3 +7,6 @@ Steps to rebuild the docker image: 5. `rushx pack` 6. `cd ../.. # go to tools/sdk-generation-pipeline` 7. `docker build -t sdkgeneration.azurecr.io/sdk-generation:beta-1.0 .` +7. `docker push sdkgeneration.azurecr.io/sdk-generation:beta-1.0` +## Rebuild docker In Pipeline +https://dev.azure.com/azure-sdk/internal/_build?definitionId=5980