Skip to content
Merged
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
66 changes: 43 additions & 23 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,26 @@ on:
release:
types: [created]

env:
RUST_VERSION: 1.80

jobs:
detect-windows-dockerfile:
runs-on: ubuntu-latest
outputs:
has_dockerfile: ${{ steps.check.outputs.has }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- id: check
name: Check for Dockerfile.windows
run: |
if [ -f Dockerfile.windows ]; then
echo "has=true" >> $GITHUB_OUTPUT
else
echo "has=false" >> $GITHUB_OUTPUT
fi

linux-build:
runs-on: ubuntu-latest
permissions:
Expand All @@ -29,40 +48,43 @@ jobs:
push: true
platforms: linux/amd64,linux/arm64,linux/arm/v7
tags: ghcr.io/${{ github.repository_owner }}/resonix-node:linux-latest
build-args: |
RUST_VERSION=${{ env.RUST_VERSION }}

windows-build:
needs: detect-windows-dockerfile
if: needs.detect-windows-dockerfile.outputs.has_dockerfile == 'true'
runs-on: windows-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker (Windows)
run: docker version
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Windows amd64 image
- name: Build and push Windows image (amd64)
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.windows
push: true
platforms: windows/amd64
tags: ghcr.io/${{ github.repository_owner }}/resonix-node:windows-amd64-latest
tags: ghcr.io/${{ github.repository_owner }}/resonix-node:windows-latest
build-args: |
RUST_VERSION=${{ env.RUST_VERSION }}

manifest:
create-manifest:
needs: [linux-build, windows-build]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Log in to GHCR
Expand All @@ -71,20 +93,18 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push multi-platform manifest (linux + windows)
- name: Create and push manifest (latest)
run: |
set -eux
IMAGE=ghcr.io/${{ github.repository_owner }}/resonix-node
# Pull images built in previous jobs
docker pull $IMAGE:linux-latest
docker pull $IMAGE:windows-amd64-latest
# Retag per platform
docker tag $IMAGE:linux-latest $IMAGE:latest-linux
docker tag $IMAGE:windows-amd64-latest $IMAGE:latest-windows-amd64
# Create manifest referencing both
docker manifest create $IMAGE:latest \
--amend $IMAGE:latest-linux \
--amend $IMAGE:latest-windows-amd64 || true
# Annotate (linux manifest already multi-arch)
docker manifest annotate $IMAGE:latest $IMAGE:latest-windows-amd64 --os windows --arch amd64 || true
docker manifest push --purge $IMAGE:latest
set -e
# If windows build succeeded, include both; else only linux
if [ "${{ needs.windows-build.result }}" = "success" ]; then
docker buildx imagetools create \
-t ghcr.io/${{ github.repository_owner }}/resonix-node:latest \
ghcr.io/${{ github.repository_owner }}/resonix-node:linux-latest \
ghcr.io/${{ github.repository_owner }}/resonix-node:windows-latest
else
docker buildx imagetools create \
-t ghcr.io/${{ github.repository_owner }}/resonix-node:latest \
ghcr.io/${{ github.repository_owner }}/resonix-node:linux-latest
fi
docker buildx imagetools inspect ghcr.io/${{ github.repository_owner }}/resonix-node:latest
44 changes: 30 additions & 14 deletions Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
# Builder stage (Windows)
ARG RUST_VERSION=1.80
FROM rust:${RUST_VERSION}-windowsservercore-ltsc2022 AS builder
SHELL ["cmd", "/S", "/C"]
# Builder Stage
ARG RUST_VERSION=1.80.0
FROM mcr.microsoft.com/windows/servercore:ltsc2022 AS builder
SHELL ["powershell","-NoLogo","-ExecutionPolicy","Bypass","-Command"]

ENV RUSTUP_HOME=C:\rust\rustup \
CARGO_HOME=C:\rust\cargo \
PATH=C:\rust\cargo\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\

RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; \
Invoke-WebRequest https://static.rust-lang.org/rustup/init.exe -OutFile rustup-init.exe ; \
Start-Process .\rustup-init.exe -ArgumentList ('-y','--profile','minimal','--default-toolchain',"'+$env:RUST_VERSION+'") -NoNewWindow -Wait ; \
Remove-Item rustup-init.exe -Force ; \
rustc -V ; cargo -V

WORKDIR C:\app
COPY . .

RUN set RUSTFLAGS= && cargo build --release
COPY Cargo.toml Cargo.lock* .\

RUN New-Item -ItemType Directory src | Out-Null; \
Set-Content -Path src\lib.rs -Value "fn main(){}"; \
cargo build --release || echo "(Ignoring expected build failure during dependency fetch warm-up)"

COPY . .
RUN cargo build --release --locked

# Runtime stage
# Runtime Stage
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
SHELL ["powershell","-NoLogo","-ExecutionPolicy","Bypass","-Command"]
WORKDIR C:\app

COPY --from=builder C:/app/target/release/resonix-node.exe C:/app/resonix-node.exe
COPY --from=builder C:/Windows/System32/vcruntime140.dll C:/Windows/System32/vcruntime140.dll
COPY --from=builder C:/Windows/System32/vcruntime140_1.dll C:/Windows/System32/vcruntime140_1.dll
COPY --from=builder C:/Windows/System32/msvcp140.dll C:/Windows/System32/msvcp140.dll

COPY --from=builder C:\app\target\release\resonix-node.exe C:\app\resonix-node.exe
COPY assets/ /app/assets/
EXPOSE 0-65535

ENV RUST_LOG=info
ENTRYPOINT ["C:/app/resonix-node.exe"]
EXPOSE 0-65535

ENTRYPOINT ["C:\\app\\resonix-node.exe"]