Skip to content
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

windows attempt #54

Closed
Closed
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
64 changes: 63 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -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"]
21 changes: 21 additions & 0 deletions Dockerfile.windows.nano
Original file line number Diff line number Diff line change
@@ -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"]