Skip to content

Commit 3088923

Browse files
authored
Merge pull request #25 from resonix-dev/development
chore: enhance Docker workflow for multi-platform builds and improve Windows Dockerfile
2 parents d6a0c00 + a44c34c commit 3088923

File tree

2 files changed

+73
-37
lines changed

2 files changed

+73
-37
lines changed

.github/workflows/publish-docker.yml

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,26 @@ on:
44
release:
55
types: [created]
66

7+
env:
8+
RUST_VERSION: 1.80
9+
710
jobs:
11+
detect-windows-dockerfile:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
has_dockerfile: ${{ steps.check.outputs.has }}
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
- id: check
19+
name: Check for Dockerfile.windows
20+
run: |
21+
if [ -f Dockerfile.windows ]; then
22+
echo "has=true" >> $GITHUB_OUTPUT
23+
else
24+
echo "has=false" >> $GITHUB_OUTPUT
25+
fi
26+
827
linux-build:
928
runs-on: ubuntu-latest
1029
permissions:
@@ -29,40 +48,43 @@ jobs:
2948
push: true
3049
platforms: linux/amd64,linux/arm64,linux/arm/v7
3150
tags: ghcr.io/${{ github.repository_owner }}/resonix-node:linux-latest
51+
build-args: |
52+
RUST_VERSION=${{ env.RUST_VERSION }}
3253
3354
windows-build:
55+
needs: detect-windows-dockerfile
56+
if: needs.detect-windows-dockerfile.outputs.has_dockerfile == 'true'
3457
runs-on: windows-latest
3558
permissions:
3659
contents: read
3760
packages: write
3861
steps:
3962
- name: Checkout repository
4063
uses: actions/checkout@v4
41-
- name: Set up Docker (Windows)
42-
run: docker version
4364
- name: Set up Docker Buildx
4465
uses: docker/setup-buildx-action@v3
45-
with:
46-
driver: docker
4766
- name: Log in to GHCR
4867
uses: docker/login-action@v3
4968
with:
5069
registry: ghcr.io
5170
username: ${{ github.actor }}
5271
password: ${{ secrets.GITHUB_TOKEN }}
53-
- name: Build and push Windows amd64 image
72+
- name: Build and push Windows image (amd64)
5473
uses: docker/build-push-action@v5
5574
with:
5675
context: .
5776
file: ./Dockerfile.windows
5877
push: true
5978
platforms: windows/amd64
60-
tags: ghcr.io/${{ github.repository_owner }}/resonix-node:windows-amd64-latest
79+
tags: ghcr.io/${{ github.repository_owner }}/resonix-node:windows-latest
80+
build-args: |
81+
RUST_VERSION=${{ env.RUST_VERSION }}
6182
62-
manifest:
83+
create-manifest:
6384
needs: [linux-build, windows-build]
6485
runs-on: ubuntu-latest
6586
permissions:
87+
contents: read
6688
packages: write
6789
steps:
6890
- name: Log in to GHCR
@@ -71,20 +93,18 @@ jobs:
7193
registry: ghcr.io
7294
username: ${{ github.actor }}
7395
password: ${{ secrets.GITHUB_TOKEN }}
74-
- name: Create and push multi-platform manifest (linux + windows)
96+
- name: Create and push manifest (latest)
7597
run: |
76-
set -eux
77-
IMAGE=ghcr.io/${{ github.repository_owner }}/resonix-node
78-
# Pull images built in previous jobs
79-
docker pull $IMAGE:linux-latest
80-
docker pull $IMAGE:windows-amd64-latest
81-
# Retag per platform
82-
docker tag $IMAGE:linux-latest $IMAGE:latest-linux
83-
docker tag $IMAGE:windows-amd64-latest $IMAGE:latest-windows-amd64
84-
# Create manifest referencing both
85-
docker manifest create $IMAGE:latest \
86-
--amend $IMAGE:latest-linux \
87-
--amend $IMAGE:latest-windows-amd64 || true
88-
# Annotate (linux manifest already multi-arch)
89-
docker manifest annotate $IMAGE:latest $IMAGE:latest-windows-amd64 --os windows --arch amd64 || true
90-
docker manifest push --purge $IMAGE:latest
98+
set -e
99+
# If windows build succeeded, include both; else only linux
100+
if [ "${{ needs.windows-build.result }}" = "success" ]; then
101+
docker buildx imagetools create \
102+
-t ghcr.io/${{ github.repository_owner }}/resonix-node:latest \
103+
ghcr.io/${{ github.repository_owner }}/resonix-node:linux-latest \
104+
ghcr.io/${{ github.repository_owner }}/resonix-node:windows-latest
105+
else
106+
docker buildx imagetools create \
107+
-t ghcr.io/${{ github.repository_owner }}/resonix-node:latest \
108+
ghcr.io/${{ github.repository_owner }}/resonix-node:linux-latest
109+
fi
110+
docker buildx imagetools inspect ghcr.io/${{ github.repository_owner }}/resonix-node:latest

Dockerfile.windows

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,38 @@
1-
# Builder stage (Windows)
2-
ARG RUST_VERSION=1.80
3-
FROM rust:${RUST_VERSION}-windowsservercore-ltsc2022 AS builder
4-
SHELL ["cmd", "/S", "/C"]
1+
# Builder Stage
2+
ARG RUST_VERSION=1.80.0
3+
FROM mcr.microsoft.com/windows/servercore:ltsc2022 AS builder
4+
SHELL ["powershell","-NoLogo","-ExecutionPolicy","Bypass","-Command"]
5+
6+
ENV RUSTUP_HOME=C:\rust\rustup \
7+
CARGO_HOME=C:\rust\cargo \
8+
PATH=C:\rust\cargo\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\
9+
10+
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; \
11+
Invoke-WebRequest https://static.rust-lang.org/rustup/init.exe -OutFile rustup-init.exe ; \
12+
Start-Process .\rustup-init.exe -ArgumentList ('-y','--profile','minimal','--default-toolchain',"'+$env:RUST_VERSION+'") -NoNewWindow -Wait ; \
13+
Remove-Item rustup-init.exe -Force ; \
14+
rustc -V ; cargo -V
15+
516
WORKDIR C:\app
6-
COPY . .
717

8-
RUN set RUSTFLAGS= && cargo build --release
18+
COPY Cargo.toml Cargo.lock* .\
19+
20+
RUN New-Item -ItemType Directory src | Out-Null; \
21+
Set-Content -Path src\lib.rs -Value "fn main(){}"; \
22+
cargo build --release || echo "(Ignoring expected build failure during dependency fetch warm-up)"
23+
24+
COPY . .
25+
RUN cargo build --release --locked
926

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

14-
COPY --from=builder C:/app/target/release/resonix-node.exe C:/app/resonix-node.exe
15-
COPY --from=builder C:/Windows/System32/vcruntime140.dll C:/Windows/System32/vcruntime140.dll
16-
COPY --from=builder C:/Windows/System32/vcruntime140_1.dll C:/Windows/System32/vcruntime140_1.dll
17-
COPY --from=builder C:/Windows/System32/msvcp140.dll C:/Windows/System32/msvcp140.dll
18-
32+
COPY --from=builder C:\app\target\release\resonix-node.exe C:\app\resonix-node.exe
1933
COPY assets/ /app/assets/
20-
EXPOSE 0-65535
34+
2135
ENV RUST_LOG=info
22-
ENTRYPOINT ["C:/app/resonix-node.exe"]
36+
EXPOSE 0-65535
37+
38+
ENTRYPOINT ["C:\\app\\resonix-node.exe"]

0 commit comments

Comments
 (0)