Skip to content

Commit 958a653

Browse files
authored
fix: various optimizations (#82)
1 parent 5f24db9 commit 958a653

File tree

4 files changed

+71
-44
lines changed

4 files changed

+71
-44
lines changed

.dockerignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Git files
2+
.git/
3+
.github/
4+
.gitignore
5+
.gitattributes
6+
7+
# Python virtual environments and caches
8+
venv/
9+
.mypy_cache/
10+
__pycache__/
11+
*.pyc
12+
*.pyo
13+
*.pyd
14+
15+
# Development
16+
*.log
17+
18+
# Documentation and README files
19+
*.md
20+
readme/
21+
22+
# Build and development scripts
23+
Makefile
24+
test_cluster.sh
25+
run_examples.sh
26+
update_slurmfiles.sh
27+
28+
# Environment files (these should be set at build time via --build-arg)
29+
.env
30+
.env.example
31+
32+
# IDE and editor files
33+
.vscode/
34+
.idea/
35+
*.swp
36+
*.swo
37+
*~
38+
39+
# OS files
40+
.DS_Store
41+
Thumbs.db

Dockerfile

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ ARG TARGETARCH
1616
# Install RPM build tools and dependencies
1717
RUN set -ex \
1818
&& dnf makecache \
19-
&& dnf -y update \
2019
&& dnf -y install dnf-plugins-core epel-release \
2120
&& dnf config-manager --set-enabled crb \
2221
&& dnf makecache \
@@ -92,17 +91,14 @@ LABEL org.opencontainers.image.source="https://github.com/giovtorres/slurm-docke
9291
ARG SLURM_VERSION
9392
ARG TARGETARCH
9493

95-
# Enable CRB and EPEL repositories for runtime dependencies
94+
# Enable CRB and EPEL repositories, then install runtime dependencies
9695
RUN set -ex \
97-
&& dnf makecache \
9896
&& dnf -y update \
9997
&& dnf -y install dnf-plugins-core epel-release \
10098
&& dnf config-manager --set-enabled crb \
101-
&& dnf makecache
102-
103-
# Install runtime dependencies only
104-
RUN set -ex \
99+
&& dnf makecache \
105100
&& dnf -y install \
101+
apptainer \
106102
bash-completion \
107103
bzip2 \
108104
gettext \
@@ -132,16 +128,21 @@ RUN set -ex \
132128

133129
# Install gosu for privilege dropping
134130
ARG GOSU_VERSION=1.19
131+
# Official SHA256 checksums from https://github.com/tianon/gosu/releases/download/1.19/SHA256SUMS
132+
ARG GOSU_SHA256_AMD64=52c8749d0142edd234e9d6bd5237dff2d81e71f43537e2f4f66f75dd4b243dd0
133+
ARG GOSU_SHA256_ARM64=3a8ef022d82c0bc4a98bcb144e77da714c25fcfa64dccc57f6aba7ae47ff1a44
135134

136135
RUN set -ex \
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" \
140-
&& export GNUPGHOME="$(mktemp -d)" \
141-
&& gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
142-
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
143-
&& rm -rf "${GNUPGHOME}" /usr/local/bin/gosu.asc \
136+
&& echo "Installing gosu ${GOSU_VERSION} for architecture: ${TARGETARCH}" \
137+
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${TARGETARCH}" \
138+
&& EXPECTED_SHA256=$(case "${TARGETARCH}" in \
139+
amd64) echo "${GOSU_SHA256_AMD64}" ;; \
140+
arm64) echo "${GOSU_SHA256_ARM64}" ;; \
141+
*) echo "Unsupported architecture: ${TARGETARCH}" && exit 1 ;; \
142+
esac) \
143+
&& echo "${EXPECTED_SHA256} /usr/local/bin/gosu" | sha256sum -c - \
144144
&& chmod +x /usr/local/bin/gosu \
145+
&& gosu --version \
145146
&& gosu nobody true
146147

147148
COPY --from=builder /root/rpmbuild/RPMS/*/*.rpm /tmp/rpms/
@@ -158,27 +159,14 @@ RUN set -ex \
158159
&& rm -rf /tmp/rpms \
159160
&& dnf clean all
160161

161-
# Install Singularity
162-
RUN set -ex \
163-
&& dnf -y install \
164-
apptainer \
165-
&& dnf clean all \
166-
&& rm -rf /var/cache/dnf
167-
168-
# Create slurm user and group
162+
# Create users, generate munge key, and set up directories
169163
RUN set -x \
170164
&& groupadd -r --gid=990 slurm \
171165
&& useradd -r -g slurm --uid=990 slurm \
172166
&& groupadd -r --gid=991 slurmrest \
173-
&& useradd -r -g slurmrest --uid=991 slurmrest
174-
175-
# Fix /etc permissions and create munge key
176-
RUN set -x \
167+
&& useradd -r -g slurmrest --uid=991 slurmrest \
177168
&& chmod 0755 /etc \
178-
&& /sbin/create-munge-key
179-
180-
# Create slurm dirs with correct ownership
181-
RUN set -x \
169+
&& /sbin/create-munge-key \
182170
&& mkdir -m 0755 -p \
183171
/var/run/slurm \
184172
/var/spool/slurm \

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help build up start down clean logs test status shell logs-slurmctld logs-slurmdbd update-slurm reload-slurm version set-version build-all test-all test-version
1+
.PHONY: help build build-no-cache up start down clean logs test status shell logs-slurmctld logs-slurmdbd update-slurm reload-slurm version set-version build-all test-all test-version
22

33
# Default target
44
.DEFAULT_GOAL := help
@@ -17,6 +17,7 @@ help: ## Show this help message
1717
@echo ""
1818
@echo "Cluster Management:"
1919
@printf " ${CYAN}%-15s${RESET} %s\n" "build" "Build Docker images"
20+
@printf " ${CYAN}%-15s${RESET} %s\n" "build-no-cache" "Build Docker images without cache"
2021
@printf " ${CYAN}%-15s${RESET} %s\n" "up" "Start containers"
2122
@printf " ${CYAN}%-15s${RESET} %s\n" "down" "Stop containers"
2223
@printf " ${CYAN}%-15s${RESET} %s\n" "clean" "Remove containers and volumes"
@@ -54,6 +55,9 @@ help: ## Show this help message
5455
build: ## Build Docker images
5556
docker compose --progress plain build
5657

58+
build-no-cache: ## Build Docker images without cache
59+
docker compose --progress plain build --no-cache
60+
5761
up: ## Start containers
5862
docker compose up -d
5963

README.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ git clone https://github.com/giovtorres/slurm-docker-cluster.git
2323
cd slurm-docker-cluster
2424
```
2525

26-
## 🔢 Choosing Your Slurm Version
26+
### 🔢 Choosing Your Slurm Version
2727

2828
This project supports multiple Slurm versions. To select your version, copy `.env.example` to `.env` and set `SLURM_VERSION`:
2929

@@ -37,33 +37,27 @@ SLURM_VERSION=24.11.6 # Previous stable release
3737

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

40-
## 🏗️ Architecture Support
40+
### 🏗️ Architecture Support
4141

4242
This project supports both **AMD64 (x86_64)** and **ARM64 (aarch64)**
4343
architectures. The build system automatically detects your architecture. No
44-
special configuration is needed - simply build and run:
44+
special configuration is needed - simply build and run.
45+
46+
## Build and start the cluster
4547

4648
```bash
4749
make build
4850
make up
4951
```
5052

51-
## 🚀 Quick Start (Using Make)
52-
53-
The easiest way to get started is using the provided Makefile:
53+
### View cluster status
5454

5555
```bash
56-
# Build and start the cluster
57-
make up
58-
59-
# Run tests to verify everything works
60-
make test
61-
62-
# View cluster status
6356
make status
6457
```
6558

6659
See all available commands:
60+
6761
```bash
6862
make help
6963
```

0 commit comments

Comments
 (0)