Skip to content

Commit f46b52c

Browse files
authored
feat: support both amd64 and arm64 architectures (#69)
1 parent fb89cd5 commit f46b52c

File tree

9 files changed

+62
-59
lines changed

9 files changed

+62
-59
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,67 +8,29 @@ on:
88
workflow_dispatch: # Allow manual trigger
99

1010
jobs:
11-
# Build images for all supported versions
12-
build:
13-
runs-on: ubuntu-latest
14-
timeout-minutes: 30
15-
strategy:
16-
matrix:
17-
slurm_version: ['25.05.3', '24.11.6']
18-
19-
steps:
20-
- name: Checkout code
21-
uses: actions/checkout@v4
22-
23-
- name: Set up Docker Buildx
24-
uses: docker/setup-buildx-action@v3
25-
26-
- name: Build Docker image for Slurm ${{ matrix.slurm_version }}
27-
run: |
28-
echo "SLURM_VERSION=${{ matrix.slurm_version }}" > .env
29-
docker compose build
30-
31-
- name: Save Docker image
32-
run: |
33-
docker save slurm-docker-cluster:${{ matrix.slurm_version }} | gzip > slurm-${{ matrix.slurm_version }}.tar.gz
34-
35-
- name: Upload image artifact
36-
uses: actions/upload-artifact@v4
37-
with:
38-
name: slurm-image-${{ matrix.slurm_version }}
39-
path: slurm-${{ matrix.slurm_version }}.tar.gz
40-
retention-days: 1
41-
42-
# Test cluster functionality on all versions
4311
test-cluster:
44-
needs: build
45-
runs-on: ubuntu-latest
12+
runs-on: ${{ matrix.runner }}
4613
timeout-minutes: 30
4714
strategy:
15+
fail-fast: false # Allow all matrix jobs to complete independently
4816
matrix:
4917
slurm_version: ['25.05.3', '24.11.6']
18+
runner: ['ubuntu-latest', 'ubuntu-24.04-arm']
19+
include:
20+
- runner: ubuntu-latest
21+
arch: amd64
22+
- runner: ubuntu-24.04-arm
23+
arch: arm64
5024

5125
steps:
5226
- name: Checkout code
5327
uses: actions/checkout@v4
5428

55-
- name: Download image artifact
56-
uses: actions/download-artifact@v4
57-
with:
58-
name: slurm-image-${{ matrix.slurm_version }}
59-
60-
- name: Load Docker image
61-
run: |
62-
docker load < slurm-${{ matrix.slurm_version }}.tar.gz
63-
docker images
64-
65-
- name: Configure version
29+
- name: Build and start cluster for Slurm ${{ matrix.slurm_version }} (${{ matrix.arch }})
6630
run: |
6731
echo "SLURM_VERSION=${{ matrix.slurm_version }}" > .env
6832
cat .env
69-
70-
- name: Start cluster with 2 nodes
71-
run: |
33+
docker compose build
7234
docker compose up -d
7335
echo "Waiting for services to start..."
7436
sleep 15

Dockerfile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ARG SLURM_VERSION
1010
FROM rockylinux/rockylinux:9 AS builder
1111

1212
ARG SLURM_VERSION
13+
ARG TARGETARCH
1314

1415
# Enable CRB and EPEL repositories for development packages
1516
RUN set -ex \
@@ -66,12 +67,19 @@ RUN rpmdev-setuptree
6667
COPY rpmbuild/slurm.rpmmacros /root/.rpmmacros
6768

6869
# Download official Slurm release tarball and build RPMs with slurmrestd enabled
70+
# Architecture mapping: Docker TARGETARCH (amd64, arm64) -> RPM arch (x86_64, aarch64)
6971
RUN set -ex \
72+
&& RPM_ARCH=$(case "${TARGETARCH}" in \
73+
amd64) echo "x86_64" ;; \
74+
arm64) echo "aarch64" ;; \
75+
*) echo "Unsupported architecture: ${TARGETARCH}" && exit 1 ;; \
76+
esac) \
77+
&& echo "Building Slurm RPMs for architecture: ${RPM_ARCH}" \
7078
&& wget -O /root/rpmbuild/SOURCES/slurm-${SLURM_VERSION}.tar.bz2 \
7179
https://download.schedmd.com/slurm/slurm-${SLURM_VERSION}.tar.bz2 \
7280
&& cd /root/rpmbuild/SOURCES \
7381
&& rpmbuild -ta slurm-${SLURM_VERSION}.tar.bz2 \
74-
&& ls -lh /root/rpmbuild/RPMS/x86_64/
82+
&& ls -lh /root/rpmbuild/RPMS/${RPM_ARCH}/
7583

7684
# ============================================================================
7785
# Stage 2: Runtime image
@@ -84,6 +92,7 @@ LABEL org.opencontainers.image.source="https://github.com/giovtorres/slurm-docke
8492
maintainer="Giovanni Torres"
8593

8694
ARG SLURM_VERSION
95+
ARG TARGETARCH
8796

8897
# Enable CRB and EPEL repositories for runtime dependencies
8998
RUN set -ex \
@@ -125,17 +134,17 @@ RUN set -ex \
125134
ARG GOSU_VERSION=1.19
126135

127136
RUN set -ex \
128-
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-amd64" \
129-
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-amd64.asc" \
137+
&& echo "Installing gosu for architecture: ${TARGETARCH}" \
138+
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-${TARGETARCH}" \
139+
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-${TARGETARCH}.asc" \
130140
&& export GNUPGHOME="$(mktemp -d)" \
131141
&& gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
132142
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
133143
&& rm -rf "${GNUPGHOME}" /usr/local/bin/gosu.asc \
134144
&& chmod +x /usr/local/bin/gosu \
135145
&& gosu nobody true
136146

137-
# Copy Slurm RPMs from builder stage
138-
COPY --from=builder /root/rpmbuild/RPMS/x86_64/*.rpm /tmp/rpms/
147+
COPY --from=builder /root/rpmbuild/RPMS/*/*.rpm /tmp/rpms/
139148

140149
# Install Slurm RPMs
141150
RUN set -ex \
@@ -203,7 +212,6 @@ RUN set -ex \
203212
&& rm -rf /tmp/slurm-config
204213
COPY --chown=slurm:slurm --chmod=0600 examples /root/examples
205214

206-
# Copy entrypoint script
207215
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
208216
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
209217

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ SLURM_VERSION=24.11.6 # Previous stable release
3737

3838
**Supported versions:** 25.05.x, 24.11.x
3939

40+
## 🏗️ Architecture Support
41+
42+
This project supports both **AMD64 (x86_64)** and **ARM64 (aarch64)**
43+
architectures. The build system automatically detects your architecture. No
44+
special configuration is needed - simply build and run:
45+
46+
```bash
47+
make build
48+
make up
49+
```
50+
4051
## 🚀 Quick Start (Using Make)
4152

4253
The easiest way to get started is using the provided Makefile:
@@ -191,6 +202,23 @@ For more workflows including configuration updates, version switching, and testi
191202

192203
## ⚙️ Advanced Configuration
193204

205+
### Multi-Architecture Builds
206+
207+
For cross-platform builds or explicit architecture selection (`arm64` or
208+
`amd64`), use Docker Buildx:
209+
210+
```bash
211+
docker buildx build \
212+
--platform linux/arm64 \
213+
--build-arg SLURM_VERSION=25.05.3 \
214+
--build-arg TARGETARCH=arm64 \
215+
--load \
216+
-t slurm-docker-cluster:25.05.3 \
217+
.
218+
```
219+
220+
**Note**: Cross-platform builds use QEMU emulation and may be slower than native builds.
221+
194222
### Live Configuration Updates
195223

196224
With the `etc_slurm` volume mounted, you can modify configurations without rebuilding:

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ services:
2525
context: .
2626
args:
2727
SLURM_VERSION: ${SLURM_VERSION:-25.05.3}
28+
cache_from:
29+
- slurm-docker-cluster:${SLURM_VERSION:-25.05.3}
2830
command: ["slurmdbd"]
2931
container_name: slurmdbd
3032
hostname: slurmdbd

docker-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ then
8181
if [ -f /proc/self/cgroup ]; then
8282
# Extract container name from cgroup path
8383
# Format: 0::/docker/<container_id> or similar
84-
CONTAINER_NAME=$(cat /proc/self/cgroup | grep -oP '/docker/\K[^/]+' | head -1)
84+
CONTAINER_NAME=$(cat /proc/self/cgroup | sed -n 's|.*/docker/\([^/]*\).*|\1|p' | head -1)
8585
fi
8686

8787
# If we got a container ID, try to resolve it to a name using the host's /proc

rpmbuild/slurm.rpmmacros

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@
1919

2020
# MySQL/MariaDB support
2121
%with_mysql "--with-mysql_config=/usr/bin"
22+
23+
# Disable InfiniBand/OFED support (not available on ARM64 and not needed for Docker-based testing)
24+
%_without_ofed 1

run_examples.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ case $choice in
3838
job_name=$(basename "$job_script")
3939
echo -e "${YELLOW}[SUBMIT]${NC} $job_name"
4040

41-
job_id=$(docker exec slurmctld bash -c "cd /data && sbatch examples/$job_name 2>&1" | grep -oP 'Submitted batch job \K\d+' || echo "")
41+
job_id=$(docker exec slurmctld bash -c "cd /data && sbatch examples/$job_name 2>&1" | sed -n 's/.*Submitted batch job \([0-9][0-9]*\).*/\1/p')
4242

4343
if [ -n "$job_id" ]; then
4444
echo -e "${GREEN}${NC} Job ID: $job_id"
@@ -80,7 +80,7 @@ case $choice in
8080

8181
echo ""
8282
echo -e "${YELLOW}[SUBMIT]${NC} $job_name"
83-
job_id=$(docker exec slurmctld bash -c "cd /data && sbatch examples/$job_name 2>&1" | grep -oP 'Submitted batch job \K\d+' || echo "")
83+
job_id=$(docker exec slurmctld bash -c "cd /data && sbatch examples/$job_name 2>&1" | sed -n 's/.*Submitted batch job \([0-9][0-9]*\).*/\1/p')
8484

8585
if [ -n "$job_id" ]; then
8686
echo -e "${GREEN}${NC} Job ID: $job_id submitted"

test_cluster.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ test_job_submission() {
183183
print_test "Testing job submission..."
184184

185185
# Submit a simple job
186-
JOB_ID=$(docker exec slurmctld bash -c "cd /data && sbatch --wrap='hostname' 2>&1" | grep -oP 'Submitted batch job \K\d+')
186+
JOB_ID=$(docker exec slurmctld bash -c "cd /data && sbatch --wrap='hostname' 2>&1" | sed -n 's/.*Submitted batch job \([0-9][0-9]*\).*/\1/p')
187187

188188
if [ -n "$JOB_ID" ]; then
189189
print_info " Job ID: $JOB_ID submitted"

update_slurmfiles.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if [ -z "$SLURM_VERSION" ]; then
1414
fi
1515

1616
# Extract major.minor version (e.g., 25.05 from 25.05.3)
17-
VERSION_DIR=$(echo "$SLURM_VERSION" | grep -oP '^\d+\.\d+')
17+
VERSION_DIR=$(echo "$SLURM_VERSION" | cut -d. -f1-2)
1818

1919
restart=false
2020

0 commit comments

Comments
 (0)