Skip to content

Commit

Permalink
Merge pull request #60 from HarrisonWAffel/enhanced-stability
Browse files Browse the repository at this point in the history
[RFC-13] Refactor `run.ps1`
  • Loading branch information
HarrisonWAffel authored Oct 18, 2024
2 parents 7122b8a + dcab8e9 commit b5a25f2
Show file tree
Hide file tree
Showing 10 changed files with 269 additions and 121 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci-on-pull-requset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ jobs:
strategy:
matrix:
include:
- SERVERCORE_VERSION: 1809
- NANOSERVER_VERSION: 1809
TAG_SUFFIX: windows-1809-amd64
RUNNER: windows-2019
- SERVERCORE_VERSION: ltsc2022
- NANOSERVER_VERSION: ltsc2022
TAG_SUFFIX: windows-ltsc2022-amd64
RUNNER: windows-2022
runs-on: ${{ matrix.RUNNER }}
Expand All @@ -83,7 +83,7 @@ jobs:
run: |
docker image build `
-f package/Dockerfile.windows `
--build-arg SERVERCORE_VERSION=${{ matrix.SERVERCORE_VERSION }} `
--build-arg NANOSERVER_VERSION=${{ matrix.NANOSERVER_VERSION }} `
-t ${{ env.IMAGE }}:${{ env.VERSION }}-${{ matrix.TAG_SUFFIX }} .
- name: Inspect image
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ jobs:
strategy:
matrix:
include:
- SERVERCORE_VERSION: 1809
- NANOSERVER_VERSION: 1809
TAG_SUFFIX: windows-1809-amd64
RUNNER: windows-2019
- SERVERCORE_VERSION: ltsc2022
- NANOSERVER_VERSION: ltsc2022
TAG_SUFFIX: windows-ltsc2022-amd64
RUNNER: windows-2022
runs-on: ${{ matrix.RUNNER }}
Expand Down Expand Up @@ -110,7 +110,7 @@ jobs:
run: |
docker image build `
-f package/Dockerfile.windows `
--build-arg SERVERCORE_VERSION=${{ matrix.SERVERCORE_VERSION }} `
--build-arg NANOSERVER_VERSION=${{ matrix.NANOSERVER_VERSION }} `
-t ${{ env.IMAGE }}:${{ env.VERSION }}-${{ matrix.TAG_SUFFIX }} .
docker push ${{ env.IMAGE }}:${{ env.VERSION }}-${{ matrix.TAG_SUFFIX }}
Expand Down
46 changes: 0 additions & 46 deletions Dockerfile-windows.dapper

This file was deleted.

41 changes: 27 additions & 14 deletions make.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
if (!(Test-Path .dapper.exe)) {
$dapperURL = "https://releases.rancher.com/dapper/latest/dapper-Windows-x86_64.exe"
Write-Host "no .dapper.exe, downloading $dapperURL"
curl.exe -sfL -o .dapper.exe $dapperURL
# Github action CI does not utilize these scripts, however they're still useful for local development.

Write-Host "
To build locally the following environment varables must be set
`$env:TAG - The rke2 tag that should be packaged within the installer image. This should match a released version of rke2 (i.e. v1.30.2+rke2r1)
`$env:NANOSERVER_VERSION (can be either ltsc2019 or 1809 for Windows server 2019 or ltsc2022 for Windows server 2022)
`$env:REPO - The dockerhub repo the image will be pushed to
"

if ((-not $env:TAG) -or ($env:TAG -eq "")) {
Write-Host "`$env:TAG must be set to a valid RKE2 release (such as 'v1.30.2+rke2r1')"
exit 1
}

if ((-not $env:NANOSERVER_VERSION) -or ($env:NANOSERVER_VERSION -eq "")) {
Write-Host "`$env:NANOSERVER_VERSION must be set to a valid server core base image version (Either 1809, ltsc2019, or ltsc2022)"
exit 1
}

if ((-not $env:REPO) -or ($env:REPO -eq "")) {
Write-Host "`$env:REPO must be set to a valid dockerhub repository"
exit 1
}

if ($args.Count -eq 0) {
Expand All @@ -10,24 +28,19 @@ if ($args.Count -eq 0) {

if ($args[0] -eq "build") {
Write-Host "Running build"
.dapper.exe -f Dockerfile-windows.dapper build
scripts\windows\build.ps1
exit
}

if ($args[0] -eq "publish") {
Write-Host "Running publish"
.dapper.exe -f Dockerfile-windows.dapper publish
scripts\windows\publish.ps1
exit
}

if ($args[0] -eq "clean") {
Remove-Item .dapper.exe
Remove-Item Dockerfile-windows.dapper* -Exclude "Dockerfile-windows.dapper"
}

if (Test-Path scripts\$($args[0]).ps1) {
.dapper.exe -f Dockerfile-windows.dapper $($args[0])
exit
$script = $args[0]
if (Test-Path scripts\$($script).ps1) {
scripts\$($args[0]).ps1
} else {
Write-Host "Could not find script $script.ps1"
}
4 changes: 2 additions & 2 deletions package/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG SERVERCORE_VERSION
ARG NANOSERVER_VERSION

FROM mcr.microsoft.com/windows/nanoserver:${SERVERCORE_VERSION}
FROM mcr.microsoft.com/windows/nanoserver:${NANOSERVER_VERSION}

COPY package/run.ps1 /bin/run.ps1
COPY artifacts/* /bin/
Loading

0 comments on commit b5a25f2

Please sign in to comment.