From ba5f8eb23d5b5b68b504865b94450cab0e9d803b Mon Sep 17 00:00:00 2001 From: James Fricker Date: Sat, 30 Nov 2024 20:43:39 +1100 Subject: [PATCH 1/4] build windows --- .github/workflows/build.yml | 69 +++++++++++++++++++++++++++++++++++-- Dockerfile.windows | 13 +++++++ 2 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 Dockerfile.windows diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9d999de..a695dad 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -146,8 +146,73 @@ 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 + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - 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@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push 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 . + + # Push the image if this is a version change on the main branch + if ('${{ needs.version.outputs.push }}' -eq 'true') { + docker push ghcr.io/prefix-dev/pixi:$env:PIXI_VERSION-$tag + } + shell: pwsh + + + - name: Run tests + if: needs.version.outputs.push == 'true' + run: | + $tag = "${{ steps.image-variables.outputs.tag }}" + $version = "${{ needs.version.outputs.new-version }}" + + docker run --rm ghcr.io/prefix-dev/pixi:${version}-${tag} pixi --version + docker run --rm ghcr.io/prefix-dev/pixi:${version}-${tag} powershell -Command "mkdir C:\app; cd C:\app; pixi init; pixi add python; pixi run python --version" + 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-22.04 permissions: contents: write @@ -162,4 +227,4 @@ jobs: uses: softprops/action-gh-release@v2 with: generate_release_notes: true - tag_name: ${{ needs.version.outputs.new-version }} + tag_name: ${{ needs.version.outputs.new-version }} \ No newline at end of file diff --git a/Dockerfile.windows b/Dockerfile.windows new file mode 100644 index 0000000..161d65d --- /dev/null +++ b/Dockerfile.windows @@ -0,0 +1,13 @@ +# escape=` + +ARG BASE_IMAGE +FROM ${BASE_IMAGE} + +ARG PIXI_VERSION + +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +RUN Invoke-WebRequest -Uri "https://github.com/prefix-dev/pixi/releases/download/v${env:PIXI_VERSION}/pixi-x86_64-pc-windows-msvc.exe" -OutFile C:\Windows\System32\pixi.exe + +RUN pixi --version + From dfe52663239d41330737b4a7fe29f81812343840 Mon Sep 17 00:00:00 2001 From: James Fricker Date: Tue, 3 Dec 2024 08:34:07 +1100 Subject: [PATCH 2/4] comments and fixes --- .github/workflows/build.yml | 39 +++++++++++++++++++++++-------------- Dockerfile.windows | 10 ++++++---- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a695dad..590be7e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -63,7 +63,8 @@ jobs: - nvidia/cuda:11.2.2-base-ubuntu20.04 steps: - name: Checkout source - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Set image variables id: image-variables env: @@ -159,18 +160,18 @@ jobs: - mcr.microsoft.com/windows/servercore:ltsc2022 steps: - name: Checkout source - uses: actions/checkout@v4 + 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" } + $tag = "servercore" echo "tag=$tag" >> $env:GITHUB_OUTPUT shell: pwsh - name: Login to GHCR - uses: docker/login-action@v3 + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 with: registry: ghcr.io username: ${{ github.actor }} @@ -182,31 +183,39 @@ jobs: 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 . - - # Push the image if this is a version change on the main branch - if ('${{ needs.version.outputs.push }}' -eq 'true') { - docker push ghcr.io/prefix-dev/pixi:$env:PIXI_VERSION-$tag - } shell: pwsh - - - name: Run tests - if: needs.version.outputs.push == 'true' + - 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 - docker run --rm ghcr.io/prefix-dev/pixi:${version}-${tag} powershell -Command "mkdir C:\app; cd C:\app; pixi init; pixi add python; pixi run python --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 + } shell: pwsh + - name: push image + if: needs.version.outputs.push == 'true' + run: | + docker push ghcr.io/prefix-dev/pixi:$env:PIXI_VERSION-$tag + - 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 diff --git a/Dockerfile.windows b/Dockerfile.windows index 161d65d..b398f7c 100644 --- a/Dockerfile.windows +++ b/Dockerfile.windows @@ -5,9 +5,11 @@ FROM ${BASE_IMAGE} ARG PIXI_VERSION -SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] +# Create a directory for Pixi +RUN mkdir C:\Pixi -RUN Invoke-WebRequest -Uri "https://github.com/prefix-dev/pixi/releases/download/v${env:PIXI_VERSION}/pixi-x86_64-pc-windows-msvc.exe" -OutFile C:\Windows\System32\pixi.exe - -RUN pixi --version +# 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 +# Set PATH environment variable +ENV PATH="C:\Pixi;${PATH}" \ No newline at end of file From b2c1c8e13140b22c9088a4a900308af073cb126e Mon Sep 17 00:00:00 2001 From: James Fricker Date: Thu, 10 Jul 2025 11:46:57 +0930 Subject: [PATCH 3/4] fixes --- .github/workflows/build.yml | 20 +++++++++++++++----- Dockerfile.windows | 9 +++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 659fe6e..65e6b29 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -156,6 +156,7 @@ jobs: 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 @@ -164,18 +165,18 @@ jobs: id: image-variables run: | $baseImage = "${{ matrix.base-image }}" - $tag = "servercore" + $tag = if ($baseImage -like "*nanoserver*") { "nanoserver" } else { "servercore" } echo "tag=$tag" >> $env:GITHUB_OUTPUT shell: pwsh - name: Login to GHCR - uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 + uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push Docker image + - name: Build Docker image env: PIXI_VERSION: ${{ needs.version.outputs.new-version }} run: | @@ -207,12 +208,21 @@ jobs: 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 rsync && rsync --version" + if ($LASTEXITCODE -ne 0) { + Write-Error "Pixi global binary test failed" + exit 1 + } shell: pwsh - - name: push image + - name: Push image if: needs.version.outputs.push == 'true' run: | - docker push ghcr.io/prefix-dev/pixi:$env:PIXI_VERSION-$tag + $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}}' diff --git a/Dockerfile.windows b/Dockerfile.windows index b398f7c..11f8760 100644 --- a/Dockerfile.windows +++ b/Dockerfile.windows @@ -5,11 +5,12 @@ FROM ${BASE_IMAGE} ARG PIXI_VERSION -# Create a directory for Pixi -RUN mkdir C:\Pixi +# 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 -# Set PATH environment variable -ENV PATH="C:\Pixi;${PATH}" \ No newline at end of file +# Set environment variables +ENV PATH="C:\Pixi;${PATH}" +ENV PIXI_HOME="C:\ProgramData\pixi" \ No newline at end of file From 03253f24998439358fd93d35316c35f5b2523ce9 Mon Sep 17 00:00:00 2001 From: James Fricker Date: Fri, 11 Jul 2025 15:24:07 +0930 Subject: [PATCH 4/4] rsync not available on conda --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 65e6b29..64643d3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -210,7 +210,7 @@ jobs: } # Test pixi global binaries are in PATH docker run --rm ghcr.io/prefix-dev/pixi:${version}-${tag} ` - cmd /c "pixi global install rsync && rsync --version" + cmd /c "pixi global install git && git --version" if ($LASTEXITCODE -ne 0) { Write-Error "Pixi global binary test failed" exit 1