Skip to content

build windows servercore image #58

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 86 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
steps:
- name: Checkout source
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set image variables
id: image-variables
env:
Expand Down Expand Up @@ -144,8 +145,91 @@ jobs:
- name: Image digest
run: echo ${{ steps.build.outputs.digest }}

build-windows:
needs: version
runs-on: windows-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
base-image:
- mcr.microsoft.com/windows/servercore:ltsc2022
- mcr.microsoft.com/windows/nanoserver:ltsc2022
steps:
- name: Checkout source
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set image variables
id: image-variables
run: |
$baseImage = "${{ matrix.base-image }}"
$tag = if ($baseImage -like "*nanoserver*") { "nanoserver" } else { "servercore" }
echo "tag=$tag" >> $env:GITHUB_OUTPUT
shell: pwsh

- name: Login to GHCR
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Docker image
env:
PIXI_VERSION: ${{ needs.version.outputs.new-version }}
run: |
$baseImage = "${{ matrix.base-image }}"
$tag = "${{ steps.image-variables.outputs.tag }}"
# Build the image
docker build `
--build-arg PIXI_VERSION=$env:PIXI_VERSION `
--build-arg BASE_IMAGE=$baseImage `
-t ghcr.io/prefix-dev/pixi:$env:PIXI_VERSION-$tag `
-f Dockerfile.windows .
shell: pwsh

- name: Test image
run: |
$tag = "${{ steps.image-variables.outputs.tag }}"
$version = "${{ needs.version.outputs.new-version }}"

# Test Pixi version
docker run --rm ghcr.io/prefix-dev/pixi:${version}-${tag} pixi --version
if ($LASTEXITCODE -ne 0) {
Write-Error "Pixi version check failed"
exit 1
}
# Test Python installation
docker run --rm ghcr.io/prefix-dev/pixi:${version}-${tag} `
cmd /c "mkdir C:\app && cd C:\app && pixi init && pixi add python && pixi run python --version"
if ($LASTEXITCODE -ne 0) {
Write-Error "Python installation and test failed"
exit 1
}
# Test pixi global binaries are in PATH
docker run --rm ghcr.io/prefix-dev/pixi:${version}-${tag} `
cmd /c "pixi global install git && git --version"
if ($LASTEXITCODE -ne 0) {
Write-Error "Pixi global binary test failed"
exit 1
}
shell: pwsh

- name: Push image
if: needs.version.outputs.push == 'true'
run: |
$tag = "${{ steps.image-variables.outputs.tag }}"
docker push ghcr.io/prefix-dev/pixi:${{ needs.version.outputs.new-version }}-$tag
shell: pwsh

- name: Image digest
run: docker inspect ghcr.io/prefix-dev/pixi:${{ needs.version.outputs.new-version }}-${{ steps.image-variables.outputs.tag }} --format '{{.RepoDigests}}'
shell: pwsh

release:
needs: [version, build]
needs: [version, build, build-windows]
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -160,4 +244,4 @@ jobs:
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2
with:
generate_release_notes: true
tag_name: ${{ needs.version.outputs.new-version }}
tag_name: ${{ needs.version.outputs.new-version }}
16 changes: 16 additions & 0 deletions Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# escape=`

ARG BASE_IMAGE
FROM ${BASE_IMAGE}

ARG PIXI_VERSION

# Create directories for Pixi
RUN mkdir C:\Pixi && mkdir C:\ProgramData\pixi

# Download Pixi
ADD https://github.com/prefix-dev/pixi/releases/download/v${PIXI_VERSION}/pixi-x86_64-pc-windows-msvc.exe C:\Pixi\pixi.exe
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while we're at it: there is also https://github.com/prefix-dev/pixi/releases/download/v0.39.0/pixi-aarch64-pc-windows-msvc.exe. wdyt of doing a multi-arch build on windows as well similar to linux?


# Set environment variables
ENV PATH="C:\Pixi;${PATH}"
ENV PIXI_HOME="C:\ProgramData\pixi"
Loading