Skip to content

Commit 1cdcea1

Browse files
croos-msftaviyerMSFT
authored andcommitted
Add Supporting Windows Docker Container Hosted API Services (Azure#22587)
* Add windowsdatacontainer and pipeline changes * Add pipeline changes * Fix hardcoded brnch * Copy git file to whichever Dockerfile path is being used * Remove changes to data-container pipeline * Setup windows pipeline * Update with correct ps1 location * Fix issues with dockerfile * Use Windows-styled folders * Add logic to replace base image * Add base_image_windows * Correctly refer to Dockerfile * Enclose in quotation marks * Only use servercore:ltsc2022
1 parent aa4af2b commit 1cdcea1

File tree

4 files changed

+79
-3
lines changed

4 files changed

+79
-3
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
schedules:
2+
- cron: "0 0 * * *"
3+
displayName: Daily build
4+
branches:
5+
include:
6+
- main
7+
always: true
8+
9+
pool:
10+
vmImage: 'windows-latest'
11+
12+
variables:
13+
IMAGE_TAG_PREFIX: $[format('1.0.{0:HHm}', pipeline.startTime)]
14+
15+
steps:
16+
- task: Docker@2
17+
displayName: Login to production ACR
18+
inputs:
19+
command: login
20+
containerRegistry: $(CONTAINER_REGISTRY_SERVICE_CONNECTION)
21+
22+
- task: Docker@2
23+
displayName: Login to dogfood ACR
24+
inputs:
25+
command: login
26+
containerRegistry: $(DOGFOOD_CONTAINER_REGISTRY_SERVICE_CONNECTION)
27+
28+
- task: CopyFiles@2
29+
inputs:
30+
SourceFolder: $(Build.SourcesDirectory)
31+
contents: .git/**
32+
targetFolder: $(Build.SourcesDirectory)\scripts\datacontainer-windows
33+
34+
- task: Docker@2
35+
displayName: Build and Push
36+
inputs:
37+
command: buildAndPush
38+
Dockerfile: scripts\datacontainer-windows\Dockerfile
39+
repository: $(CONTAINER_REGISTRY_REPOSITORY_NAME)
40+
tags: |
41+
latest

.azure-pipelines/azure-pipelines-data-container.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ variables:
1414

1515
steps:
1616
- task: Docker@2
17-
displayName: Login to production ACR
17+
displayName: Login to production ACR
1818
inputs:
1919
command: login
2020
containerRegistry: $(CONTAINER_REGISTRY_SERVICE_CONNECTION)
2121

2222
- task: Docker@2
23-
displayName: Login to dogfood ACR
23+
displayName: Login to dogfood ACR
2424
inputs:
2525
command: login
2626
containerRegistry: $(DOGFOOD_CONTAINER_REGISTRY_SERVICE_CONNECTION)
@@ -38,4 +38,4 @@ steps:
3838
Dockerfile: scripts/datacontainer/Dockerfile
3939
repository: $(CONTAINER_REGISTRY_REPOSITORY_NAME)
4040
tags: |
41-
latest
41+
latest
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM mcr.microsoft.com/windows/servercore:ltsc2022
2+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue'; $verbosePreference='Continue';"]
3+
4+
RUN mkdir Users\\Administrator\\specrepo
5+
6+
COPY .git C:\\Users\\Administrator\\specrepo\\.git
7+
8+
WORKDIR C:\\Users\\Administrator\\scripts
9+
ADD https://github.com/git-for-windows/git/releases/download/v2.12.2.windows.2/MinGit-2.12.2.2-64-bit.zip MinGit.zip
10+
RUN Expand-Archive C:\\Users\\Administrator\\scripts\\MinGit.zip -DestinationPath c:\\MinGit
11+
12+
COPY run.ps1 run.ps1
13+
14+
WORKDIR C:\\Users\\Administrator\\openapispecs
15+
ENTRYPOINT C:\\Users\\Administrator\\scripts\\run.ps1

scripts/datacontainer-windows/run.ps1

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
echo "[$timestamp] Adding git to path"
3+
$env:PATH = $env:PATH + ';C:\MinGit\cmd\;C:\MinGit\cmd'
4+
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $env:PATH
5+
6+
$timestamp= Get-Date -UFormat "%A %m/%d/%Y %R %Z"
7+
echo "[$timestamp] Copying files to \Users\Administrator\openapispecs"
8+
Copy-Item -Path "C:\Users\Administrator\specrepo\.git" -Destination "C:\Users\Administrator\openapispecs\.git" -Recurse
9+
10+
cd "C:\Users\Administrator\openapispecs\"
11+
$timestamp= Get-Date -UFormat "%A %m/%d/%Y %R %Z"
12+
echo "[$timestamp] Running 'git checkout [$specRetrievalGitBranch] -f'"
13+
git checkout $specRetrievalGitBranch -f
14+
15+
$timestamp= Get-Date -UFormat "%A %m/%d/%Y %R %Z"
16+
echo "[$timestamp] Deleting directory \Users\Administrator\specrepo"
17+
Remove-Item -Path "C:\Users\Administrator\specrepo" -Recurse
18+
19+
$timestamp= Get-Date -UFormat "%A %m/%d/%Y %R %Z"
20+
echo "[$timestamp] Init completed successfully. OpenAPI specs are present in C:\Users\Administrator\openapispecs"

0 commit comments

Comments
 (0)