Skip to content
Open
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
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git
.local
**/log/*
**/tmp/*
**/.bundle
**/config/database.yml
**/config/initializers/config_portal.rb
**/config/initializers/config_bourreau.rb
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Local Apple container deployment credentials
.local/
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,8 @@ running on the HPC where it resides.

CBRAIN is extensively documented in its [Wiki](https://github.com/aces/cbrain/wiki).


## Local deployment on macOS

To run BrainPortal and a local Bourreau worker with Apple’s `container` CLI,
see [the local deployment guide](deploy/apple-container/README.md).
40 changes: 40 additions & 0 deletions deploy/apple-container/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM docker.io/library/ruby:4.0.2-bookworm
RUN apt-get update && apt-get install -y --no-install-recommends \
default-libmysqlclient-dev mariadb-client nodejs rsync openssh-client openssh-server \
python3-pip libffi-dev libsodium-dev supervisor curl procps iproute2 && \
pip3 install --break-system-packages --no-cache-dir boutiques && rm -rf /var/lib/apt/lists/*
WORKDIR /opt/cbrain
COPY BrainPortal/Gemfile BrainPortal/Gemfile
COPY Bourreau/Gemfile Bourreau/Gemfile
RUN cd BrainPortal && bundle install --jobs 4 && \
cd ../Bourreau && bundle install --jobs 4

# Bourreau builds SIF images and the compute node executes them.
# Keep Slurm 20.11 for the existing local accounting database and cgroup-free node.
ARG CBRAIN_SLURM=0
RUN if [ "$CBRAIN_SLURM" = 1 ]; then \
printf 'deb https://archive.debian.org/debian bullseye main\n' > /etc/apt/sources.list.d/slurm-bullseye.list && \
apt-get -o Acquire::Check-Valid-Until=false update && \
apt-get install -y --no-install-recommends \
munge slurm-client/bullseye slurmctld/bullseye slurmd/bullseye slurmdbd/bullseye cpio rpm2cpio && \
rpm=apptainer-1.5.5-1.el8.aarch64.rpm && \
curl -fsSL --retry 3 -o /tmp/install-unprivileged.sh \
https://raw.githubusercontent.com/apptainer/apptainer/v1.5.5/tools/install-unprivileged.sh && \
curl -fsSL --retry 3 -o "/tmp/$rpm" \
"https://download.fedoraproject.org/pub/epel/8/Everything/aarch64/Packages/a/$rpm" && \
printf '%s %s\n' \
a097956eafa6ab3dd843ee429d0b774ed029753bfadf013b8046556228fac6f2 /tmp/install-unprivileged.sh \
113d396128088cec904f0f06a5f225deac00f40b40f10e20bdc138de25085f3d "/tmp/$rpm" | sha256sum -c - && \
bash /tmp/install-unprivileged.sh -e -d el8 -a aarch64 -v "/tmp/$rpm" /opt/apptainer && \
ln -s /opt/apptainer/bin/apptainer /usr/local/bin/apptainer && \
apptainer --version && \
rm -rf /var/lib/apt/lists/* /tmp/install-unprivileged.sh "/tmp/$rpm"; \
fi

COPY . .
RUN cd BrainPortal && bundle exec rake cbrain:plugins:install:plugins

COPY deploy/apple-container/local.rake BrainPortal/lib/tasks/apple_container_local.rake
ENV RAILS_ENV=development
EXPOSE 3000
ENTRYPOINT ["/opt/cbrain/deploy/apple-container/entrypoint.sh"]
136 changes: 136 additions & 0 deletions deploy/apple-container/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Local CBRAIN with Apple container

This runs BrainPortal, a local Bourreau (`ScirUnix`), and MariaDB in three
ARM64 Linux containers. It uses Apple's `container` CLI;
Docker Desktop and Docker Compose are not needed. `Containerfile` uses the OCI
build syntax accepted by Apple container; `.dockerignore` is its build-context
exclusion file.

## Start

Requires an Apple silicon Mac running macOS 26 or newer, Python 3, and Apple's
`container` CLI on `PATH`. Install the signed package from the
[Apple container releases](https://github.com/apple/container/releases).
The launcher checks these prerequisites before invoking container commands or
creating local state, and explains how to resolve a missing prerequisite.
The `credentials` command can still read saved credentials without the runtime.

From the repository root:

```sh
deploy/apple-container/apple-container.sh up
deploy/apple-container/apple-container.sh credentials
```

The first `up` builds the image and starts the services. Open
<http://localhost:3000> and sign in as `admin` using the generated initial
password. CBRAIN asks you to change it on first login. The initial password
command does not track subsequent password changes.

The setup creates `LocalPortal`, `LocalBourreau`, `LocalStorage`, and local
Diagnostics, Parallelizer, and CbSerializer tool configurations. The worker runs
UNIX jobs inside `cbrain-bourreau`. BrainPortal starts the execution server
and its task worker over SSH. Scientific tools and their datasets must be
installed/configured separately.

```sh
deploy/apple-container/apple-container.sh status
deploy/apple-container/apple-container.sh smoke # runs Diagnostics and verifies a saved report
deploy/apple-container/apple-container.sh logs
deploy/apple-container/apple-container.sh shell
deploy/apple-container/apple-container.sh stop
deploy/apple-container/apple-container.sh up
```

Only the portal's HTTP port (3000) is published, on `127.0.0.1`. All three
containers use the `cbrain-local` network. The portal starts Bourreau over SSH
and forwards its database connection through that SSH session. Bourreau
uses the forwarded portal identity to read and write `LocalStorage` on
the portal container. The launcher installs the SSH host keys it reads
from each container.

## Persistence and rebuilds

- `cbrain-db-data`: MariaDB database.
- `cbrain-app-data`: provider files, portal cache, SSH identity and host key,
and portal logs.
- `cbrain-bourreau-data`: task work directories, worker cache, SSH host key,
and Bourreau logs.
- `.local/apple-container/env`: generated passwords and session secret, mode 600,
excluded from Git and the image. Keep this file with database backups.

Run the launcher from the checkout that created the profile. Its containers
and volumes are shared across checkouts, while its credentials live in that
checkout's `.local` directory.

`stop` preserves containers and volumes. If MariaDB receives a new IP on restart,
`up` recreates the portal container with the new address and reuses its data
volume. Portal startup runs migrations, and `up` ensures the local resources exist.
The admin password is set when the database is first seeded.

After changing the source, let active jobs finish, then rebuild and restart
the selected profile.

```sh
deploy/apple-container/apple-container.sh rebuild
```

`rebuild` builds the image and replaces the application containers while
keeping the database, named volumes, and shared work directory. The `build`
command is available for building the image on its own.

On upgrade from the combined container, run `rebuild`.
The launcher replaces the combined app container, copies its work directories
and worker cache into the new worker volume, and updates `LocalStorage` to
use SSH. The provider keeps the same record and files. Its old cache status
entries are cleared so each app can resync through SSH.

This is a local development deployment for CBRAIN v8, using Ruby 4.0.2
and Rails 8.1 on Debian Bookworm. The Slurm profile retains Slurm 20.11
from Debian Bullseye for compatibility with its existing accounting data and
process-based job tracking. Do not expose this deployment publicly. Budget approximately 7 GB RAM for the running services
plus the image builder during builds.

The smoke check leaves its completed task and Diagnostics report in CBRAIN so
you can inspect them in the portal. Each invocation creates one small report.

## Optional Slurm profile

Select the Slurm profile in a separate shell:

```sh
export CBRAIN_LOCAL_PROFILE=slurm
deploy/apple-container/apple-container.sh up
deploy/apple-container/apple-container.sh smoke
```

Open <http://localhost:3003>. Use the same launcher commands (`credentials`,
`status`, `logs`, and `stop`) with the profile selected. The profile uses its
own containers, volumes, credentials, and database under the `cbrain-slurm`
prefix and `.local/apple-container/slurm` state directory.

Bourreau uses `ScirSlurm` and submits jobs to the separate
`cbrain-slurm-node` container. That container runs the Slurm controller,
compute daemon, and accounting daemon. Accounting uses a dedicated schema
in the profile's MariaDB. Bourreau and the compute node mount the same
`/cluster` directory for job work, cache, and Slurm configuration. Keep
the profile's state directory with its volumes to preserve that data and
the Munge key.

The Slurm image includes ARM64 Apptainer 1.5.5. For a containerized tool, set
the Tool Config's container engine to **Singularity** and select an ARM64
image. For an OCI source, use `docker://` as the index location. Bourreau
builds and caches a SIF under `/cluster/cache`, then stages it for the Slurm
job to run on the compute node. The default Diagnostics smoke test uses the
plain tool configuration.

Inspect scheduler state and job history:

```sh
container exec -e SLURM_CONF=/cluster/slurm.conf cbrain-slurm-bourreau sinfo
container exec -e SLURM_CONF=/cluster/slurm.conf cbrain-slurm-bourreau sacct -X
```

The node has two CPUs and a one-hour job limit. It uses Slurm's process-based
tracking with cgroup enforcement disabled. Allow about 9 GB of memory for
the running services.
Loading