Skip to content

Commit fa8f665

Browse files
authored
ci: add windows build pool and NPM windows dockerfile (#1073)
* build pool windows
1 parent cb866ef commit fa8f665

File tree

8 files changed

+118
-19
lines changed

8 files changed

+118
-19
lines changed

.pipelines/pipeline.yaml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ trigger:
1111
- honeycomb-dev
1212

1313
stages:
14-
- stage: build_and_test
14+
- stage: setup
1515
displayName: ACN
1616
jobs:
17-
- job: setup
17+
- job: env
1818
displayName: Setup
1919
pool:
2020
name: "$(BUILD_POOL_NAME_DEFAULT)"
@@ -32,13 +32,19 @@ stages:
3232
displayName: "Set environmental variables"
3333
condition: always()
3434
35+
36+
- template: windows-image.yaml
37+
38+
- stage: build_and_test
39+
displayName: ACN
40+
dependsOn:
41+
- "setup"
42+
jobs:
3543
- job: build
3644
displayName: Build Binaries
37-
dependsOn:
38-
- "setup"
3945
variables:
40-
TAG: $[ dependencies.setup.outputs['EnvironmentalVariables.Tag'] ]
41-
STORAGE_ID: $[ dependencies.setup.outputs['EnvironmentalVariables.StorageID'] ]
46+
TAG: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.Tag'] ]
47+
STORAGE_ID: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.StorageID'] ]
4248
pool:
4349
name: "$(BUILD_POOL_NAME_DEFAULT)"
4450
steps:
@@ -85,10 +91,8 @@ stages:
8591

8692
- job: build_images
8793
displayName: Build Images
88-
dependsOn:
89-
- "setup"
9094
variables:
91-
TAG: $[ dependencies.setup.outputs['EnvironmentalVariables.Tag'] ]
95+
TAG: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.Tag'] ]
9296
pool:
9397
name: "$(BUILD_POOL_NAME_DEFAULT)"
9498
steps:
@@ -158,10 +162,8 @@ stages:
158162

159163
- job: test
160164
displayName: Run Tests
161-
dependsOn:
162-
- "setup"
163165
variables:
164-
STORAGE_ID: $[ dependencies.setup.outputs['EnvironmentalVariables.StorageID'] ]
166+
STORAGE_ID: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.StorageID'] ]
165167
pool:
166168
name: "$(BUILD_POOL_NAME_DEFAULT)"
167169
steps:

.pipelines/singletenancy/aks-engine/e2e-job-template.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ parameters:
1010
stages:
1111
- stage: ${{ parameters.name }}
1212
displayName: E2E - ${{ parameters.displayName }}
13-
dependsOn: build_and_test
13+
dependsOn:
14+
- setup
15+
- build_and_test
1416
jobs:
1517
- job: ${{ parameters.name }}
1618
displayName: Singletenancy AKS Engine Suite - (${{ parameters.name }})
@@ -27,9 +29,9 @@ stages:
2729
GOBIN: "$(GOPATH)/bin" # Go binaries path
2830
modulePath: "$(GOPATH)/src/github.com/Azure/aks-engine"
2931
acnPath: "$(GOPATH)/src/github.com/Azure/azure-container-networking"
30-
Tag: $[ stagedependencies.build_and_test.setup.outputs['EnvironmentalVariables.Tag'] ]
31-
CommitHash: $[ stagedependencies.build_and_test.setup.outputs['EnvironmentalVariables.CommitHash'] ]
32-
StorageID: $[ stagedependencies.build_and_test.setup.outputs['EnvironmentalVariables.StorageID'] ]
32+
Tag: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.Tag'] ]
33+
CommitHash: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.CommitHash'] ]
34+
StorageID: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.StorageID'] ]
3335
steps:
3436
- template: e2e-step-template.yaml
3537
parameters:

.pipelines/singletenancy/aks-swift/e2e-job-template.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ parameters:
66
stages:
77
- stage: ${{ parameters.name }}
88
displayName: E2E - ${{ parameters.displayName }}
9-
dependsOn: build_and_test
9+
dependsOn:
10+
- setup
11+
- build_and_test
1012
jobs:
1113
- job: ${{ parameters.name }}
1214
displayName: Singletenancy AKS Swift Suite - (${{ parameters.name }})
@@ -19,7 +21,7 @@ stages:
1921
variables:
2022
GOPATH: "$(Agent.TempDirectory)/go" # Go workspace path
2123
GOBIN: "$(GOPATH)/bin" # Go binaries path
22-
Tag: $[ stagedependencies.build_and_test.setup.outputs['EnvironmentalVariables.Tag'] ]
24+
Tag: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.Tag'] ]
2325
modulePath: "$(GOPATH)/src/github.com/Azure/azure-container-networking"
2426
steps:
2527
- template: e2e-step-template.yaml

.pipelines/windows-image.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
stages:
2+
- stage: build_windows_images
3+
displayName: Build Windows Images
4+
dependsOn:
5+
- "setup"
6+
jobs:
7+
- job: NPM
8+
displayName: Build NPM
9+
variables:
10+
tag: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.Tag'] ]
11+
pool:
12+
name: "$(BUILD_POOL_NAME_DEFAULT_WINDOWS)"
13+
steps:
14+
- powershell: |
15+
powershell.exe -command "& { . .\windows.ps1; azure-npm-image $(tag)-windows-amd64 }"
16+
name: "build_npm"
17+
displayName: "Build"
18+
19+
- task: Docker@2
20+
displayName: Docker Login
21+
inputs:
22+
containerRegistry: $(ACR_SERVICE_CONNECTION)
23+
command: 'login'
24+
addPipelineData: false
25+
26+
- powershell: |
27+
docker tag acnpublic.azurecr.io/azure-npm:$(tag)-windows-amd64 acnpublic.azurecr.io/azure-npm:$(tag)-windows-amd64-test
28+
docker push acnpublic.azurecr.io/azure-npm:$(tag)-windows-amd64-test
29+
name: "push_npm"
30+
displayName: "Push"
31+
32+
- powershell: |
33+
mkdir .\output\images\windows\
34+
docker save acnpublic.azurecr.io/azure-npm:$(tag)-windows-amd64-test -o .\output\images\windows\azure-npm-$(tag)-windows-amd64.tar
35+
name: "save_npm"
36+
displayName: "Save"
37+
38+
- task: Docker@2
39+
displayName: Docker Logout
40+
inputs:
41+
containerRegistry: $(ACR_SERVICE_CONNECTION)
42+
command: 'logout'
43+
addPipelineData: false
44+
45+
- task: CopyFiles@2
46+
inputs:
47+
sourceFolder: "output"
48+
targetFolder: $(Build.ArtifactStagingDirectory)
49+
condition: succeeded()
50+
51+
- task: PublishBuildArtifacts@1
52+
inputs:
53+
artifactName: "output"
54+
pathtoPublish: "$(Build.ArtifactStagingDirectory)"
55+
condition: succeeded()

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ ifeq ($(GOOS),linux)
113113
all-binaries: azure-cnm-plugin azure-cni-plugin azure-cns azure-npm
114114
all-images: azure-npm-image azure-cns-image
115115
else
116-
all-binaries: azure-cnm-plugin azure-cni-plugin azure-cns
116+
all-binaries: azure-cnm-plugin azure-cni-plugin azure-cns azure-npm
117117
all-images:
118118
@echo "Nothing to build. Skip."
119119
endif

log/logger_windows.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ func (logger *Logger) SetTarget(target int) error {
1919
var err error
2020

2121
switch target {
22+
case TargetStdout:
23+
logger.out = os.Stdout
24+
2225
case TargetStderr:
2326
logger.out = os.Stderr
2427

npm/Dockerfile.windows

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM golang:windowsservercore-ltsc2022 AS builder
2+
# Build args
3+
ARG VERSION
4+
ARG NPM_AI_PATH
5+
ARG NPM_AI_ID
6+
7+
WORKDIR /usr/src/npm
8+
RUN mkdir /usr/bin/
9+
# Copy the source
10+
COPY . .
11+
12+
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/
13+
14+
# Copy into final image
15+
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
16+
COPY --from=builder /Windows/System32/netapi32.dll /Windows/System32/netapi32.dll
17+
COPY --from=builder /usr/bin/npm.exe \
18+
/usr/bin/npm.exe
19+
20+
ENTRYPOINT ["/usr/bin/npm.exe", "start"]

windows.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
function azure-npm-image {
3+
$env:ACN_PACKAGE_PATH = "github.com/Azure/azure-container-networking"
4+
$env:NPM_AI_ID = "014c22bd-4107-459e-8475-67909e96edcb"
5+
$env:NPM_AI_PATH="$env:ACN_PACKAGE_PATH/npm.aiMetadata"
6+
7+
if ($null -eq $env:VERSION) { $env:VERSION = $args[0] }
8+
docker build `
9+
-f npm/Dockerfile.windows `
10+
-t acnpublic.azurecr.io/azure-npm:$env:VERSION `
11+
--build-arg VERSION=$env:VERSION `
12+
--build-arg NPM_AI_PATH=$env:NPM_AI_PATH `
13+
--build-arg NPM_AI_ID=$env:NPM_AI_ID `
14+
.
15+
}

0 commit comments

Comments
 (0)