diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9d999de..482762f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -146,8 +146,70 @@ jobs: - name: Image digest run: echo ${{ steps.build.outputs.digest }} + build-windows: + needs: version + runs-on: windows-2022 + permissions: + contents: read + packages: write + strategy: + fail-fast: false + matrix: + include: + - dockerfile: Dockerfile.windows + tag: windows-servercore + - dockerfile: Dockerfile.windows.nano + tag: windows-nano + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - name: Get docker metadata + id: metadata + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 + with: + images: ghcr.io/prefix-dev/pixi + flavor: latest=false + tags: | + type=raw,value=${{ matrix.tag }},priority=900 + type=semver,pattern={{version}}-${{ matrix.tag }},value=${{ needs.version.outputs.new-version }},priority=500 + + - name: Setup docker buildx + uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 + with: + driver: docker + use-docker-driver: true + + - name: Login to GHCR + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Docker images + id: build + uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 + with: + provenance: false + platforms: windows/amd64 + push: ${{ needs.version.outputs.push == 'true' }} + file: ${{ matrix.dockerfile }} + tags: ${{ steps.metadata.outputs.tags }} + labels: ${{ steps.metadata.outputs.labels }} + + - name: Run tests + if: needs.version.outputs.push == 'true' + shell: cmd + run: | + docker run --rm ghcr.io/prefix-dev/pixi:${{ needs.version.outputs.new-version }}-${{ matrix.tag }} pixi --version + docker run --rm ghcr.io/prefix-dev/pixi:${{ needs.version.outputs.new-version }}-${{ matrix.tag }} cmd /C "mkdir app && cd app && pixi init && pixi add python && pixi run python --version" + + - name: Image digest + run: echo ${{ steps.build.outputs.digest }} + release: - needs: [version, build] + needs: [version, build, build-windows] runs-on: ubuntu-22.04 permissions: contents: write diff --git a/Dockerfile.windows b/Dockerfile.windows new file mode 100644 index 0000000..2803bc9 --- /dev/null +++ b/Dockerfile.windows @@ -0,0 +1,20 @@ +# Windows Server Core base image +FROM mcr.microsoft.com/windows/servercore:ltsc2022 AS builder +ARG PIXI_VERSION=0.36.0 + +# Set shell to PowerShell +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +# Download pixi for Windows +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:\pixi.exe; \ + Get-FileHash C:\pixi.exe; \ + C:\pixi.exe --version + +FROM mcr.microsoft.com/windows/servercore:ltsc2022 +COPY --from=builder C:\pixi.exe C:\Windows\System32\pixi.exe + +# Set working directory +WORKDIR C:\app + +# Set default command +CMD ["cmd", "/C", "pixi --version"] \ No newline at end of file diff --git a/Dockerfile.windows.nano b/Dockerfile.windows.nano new file mode 100644 index 0000000..6f53832 --- /dev/null +++ b/Dockerfile.windows.nano @@ -0,0 +1,21 @@ +# Windows Nano Server base image +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 AS builder +ARG PIXI_VERSION=0.36.0 + +# Download pixi using Windows Server Core since Nano doesn't have PowerShell +FROM mcr.microsoft.com/windows/servercore:ltsc2022 AS downloader +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:\pixi.exe; \ + Get-FileHash C:\pixi.exe; \ + C:\pixi.exe --version + +# Final Nano Server image +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 +COPY --from=downloader C:\pixi.exe C:\Windows\pixi.exe + +# Set working directory +WORKDIR C:\app + +# Set default command +CMD ["pixi", "--version"] \ No newline at end of file