-
Notifications
You must be signed in to change notification settings - Fork 260
ci: add windows build pool #1073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
088fc39
0da6591
343a5c5
96ba472
3291fcc
af45201
d4ba7c7
71fc5f8
9eea7d0
36f2d9b
f54a0ea
b9d003e
11c6a0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| stages: | ||
| - stage: build_windows_images | ||
| displayName: Build Windows Images | ||
| dependsOn: | ||
| - "setup" | ||
| jobs: | ||
| - job: NPM | ||
| displayName: Build NPM | ||
| variables: | ||
| tag: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.Tag'] ] | ||
| pool: | ||
| name: "$(BUILD_POOL_NAME_DEFAULT_WINDOWS)" | ||
| steps: | ||
| - powershell: | | ||
| powershell.exe -command "& { . .\windows.ps1; azure-npm-image $(tag)-windows-amd64 }" | ||
| name: "build_npm" | ||
| displayName: "Build" | ||
| - task: Docker@2 | ||
| displayName: Docker Login | ||
| inputs: | ||
| containerRegistry: $(ACR_SERVICE_CONNECTION) | ||
| command: 'login' | ||
| addPipelineData: false | ||
|
|
||
| - powershell: | | ||
| docker tag acnpublic.azurecr.io/azure-npm:$(tag)-windows-amd64 acnpublic.azurecr.io/azure-npm:$(tag)-windows-amd64-test | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to declare
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, but I'd like to leave this as is for the moment, and take that in #1079 since that's the theme for that pr, and this will be refactored again there |
||
| docker push acnpublic.azurecr.io/azure-npm:$(tag)-windows-amd64-test | ||
| name: "push_npm" | ||
| displayName: "Push" | ||
| - powershell: | | ||
| mkdir .\output\images\windows\ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am wondering
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think to release it, when we cut a release on this particular pipeline build these files are what get artifact'ed into binaries you see in github release. |
||
| docker save acnpublic.azurecr.io/azure-npm:$(tag)-windows-amd64-test -o .\output\images\windows\azure-npm-$(tag)-windows-amd64.tar | ||
| name: "save_npm" | ||
| displayName: "Save" | ||
| - task: Docker@2 | ||
| displayName: Docker Logout | ||
| inputs: | ||
| containerRegistry: $(ACR_SERVICE_CONNECTION) | ||
| command: 'logout' | ||
| addPipelineData: false | ||
|
|
||
| - task: CopyFiles@2 | ||
| inputs: | ||
| sourceFolder: "output" | ||
| targetFolder: $(Build.ArtifactStagingDirectory) | ||
| condition: succeeded() | ||
|
|
||
| - task: PublishBuildArtifacts@1 | ||
| inputs: | ||
| artifactName: "output" | ||
| pathtoPublish: "$(Build.ArtifactStagingDirectory)" | ||
| condition: succeeded() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,7 +113,7 @@ ifeq ($(GOOS),linux) | |
| all-binaries: azure-cnm-plugin azure-cni-plugin azure-cns azure-npm | ||
| all-images: azure-npm-image azure-cns-image | ||
| else | ||
| all-binaries: azure-cnm-plugin azure-cni-plugin azure-cns | ||
| all-binaries: azure-cnm-plugin azure-cni-plugin azure-cns azure-npm | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems possible to extract it above |
||
| all-images: | ||
| @echo "Nothing to build. Skip." | ||
| endif | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| FROM golang:windowsservercore-ltsc2022 AS builder | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's due to this issue: docker-library/golang#348 klog has a dependency on os/user, so we need to take that dll from servercore to be able to use nanoserver |
||
| # Build args | ||
| ARG VERSION | ||
| ARG NPM_AI_PATH | ||
| ARG NPM_AI_ID | ||
|
|
||
| WORKDIR /usr/src/npm | ||
| RUN mkdir /usr/bin/ | ||
| # Copy the source | ||
| COPY . . | ||
|
|
||
| RUN $Env:CGO_ENABLED=0; go build -v -o /usr/bin/npm.exe -ldflags """-X main.version=${env:VERSION} -X ${env:NPM_AI_PATH}=${env:NPM_AI_ID}""" -gcflags="-dwarflocationlists=true" ./npm/cmd/ | ||
|
|
||
| # Copy into final image | ||
| FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 | ||
| COPY --from=builder /Windows/System32/netapi32.dll /Windows/System32/netapi32.dll | ||
| COPY --from=builder /usr/bin/npm.exe \ | ||
| /usr/bin/npm.exe | ||
|
|
||
| ENTRYPOINT ["/usr/bin/npm.exe", "start"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
|
|
||
| function azure-npm-image { | ||
| $env:ACN_PACKAGE_PATH = "github.com/Azure/azure-container-networking" | ||
| $env:NPM_AI_ID = "014c22bd-4107-459e-8475-67909e96edcb" | ||
| $env:NPM_AI_PATH="$env:ACN_PACKAGE_PATH/npm.aiMetadata" | ||
|
|
||
| if ($null -eq $env:VERSION) { $env:VERSION = $args[0] } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is Is it slightly better to get above three as argument as well for maintenance?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. version is tuneable via argument so the script can be used when building locally, and tbh arguments are much easier to work with in powershell than env's imo
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the other three are very static and should not be changed |
||
| docker build ` | ||
| -f npm/Dockerfile.windows ` | ||
| -t acnpublic.azurecr.io/azure-npm:$env:VERSION ` | ||
| --build-arg VERSION=$env:VERSION ` | ||
| --build-arg NPM_AI_PATH=$env:NPM_AI_PATH ` | ||
| --build-arg NPM_AI_ID=$env:NPM_AI_ID ` | ||
| . | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: naming to clarify what they are?
windows.ps1 -> npm-image-builder.ps1
azure-npm-image -> build-azure-npm-image