diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 4c62747..2d0b5f8 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -37,6 +37,7 @@ jobs: username: ${{ env.REGISTRY_USER }} password: ${{ env.REGISTRY_PASSWORD }} + # MARK: packager - name: Build packager uses: docker/build-push-action@91df6b874e498451163feb47610c87c4a218c1ee with: @@ -57,6 +58,34 @@ jobs: name: slurm path: slurm.tar.gz + # MARK: daemon-base image + - name: Extract metadata (tags, labels) for daemon-base + id: daemon-base-meta + uses: docker/metadata-action@c4ee3adeed93b1fa6a762f209fb01608c1a22f1e + with: + images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }} + flavor: | + suffix=-daemon-base + tags: | + type=schedule + type=ref,event=branch + type=ref,event=tag + type=ref,event=pr + type=sha,format=long + + - name: Build and push daemon-base image + uses: docker/build-push-action@91df6b874e498451163feb47610c87c4a218c1ee + with: + context: . + target: daemon-base + platforms: linux/amd64 + push: true + build-args: | + DOCKER_METADATA_OUTPUT_JSON + tags: ${{ steps.daemon-base-meta.outputs.tags }} + labels: ${{ steps.daemon-base-meta.outputs.labels }} + + # MARK: slurmctld image - name: Extract metadata (tags, labels) for slurmctld id: slurmctld-meta uses: docker/metadata-action@c4ee3adeed93b1fa6a762f209fb01608c1a22f1e @@ -83,6 +112,7 @@ jobs: tags: ${{ steps.slurmctld-meta.outputs.tags }} labels: ${{ steps.slurmctld-meta.outputs.labels }} + # MARK: slurmdbd image - name: Extract metadata (tags, labels) for slurmdbd id: slurmdbd-meta uses: docker/metadata-action@c4ee3adeed93b1fa6a762f209fb01608c1a22f1e @@ -109,7 +139,8 @@ jobs: tags: ${{ steps.slurmdbd-meta.outputs.tags }} labels: ${{ steps.slurmdbd-meta.outputs.labels }} - - name: Release + # MARK: attach slurm.tar.gz to release + - name: Attach slurm.tar.gz to release uses: softprops/action-gh-release@975c1b265e11dd76618af1c374e7981f9a6ff44a if: startsWith(github.ref, 'refs/tags/') with: diff --git a/Dockerfile b/Dockerfile index 7b4be4a..7aa6493 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ +# MARK: builder FROM ubuntu:22.04 as builder RUN apt-get update && apt-get install -y wget build-essential fakeroot devscripts equivs @@ -42,6 +43,7 @@ RUN cd /tmp/builder/slurm* \ && rm -rf /tmp/builder +# MARK: packager # Package the built slurm package FROM ubuntu:22.04 as packager @@ -49,7 +51,9 @@ COPY --from=builder /opt/slurm /opt/slurm RUN tar -C /opt -czf /opt/slurm.tar.gz slurm -FROM ubuntu:22.04 as daemon_base +# MARK: daemon-base +# Base image for any daemon. Contains munge, slurm binaries, convenience scripts, and supervisord +FROM ubuntu:22.04 as daemon-base # Create the users. 60430 is the default slurm uid. 60429 for munge is arbitrary. RUN groupadd --gid 64029 munge && useradd --uid 64029 --gid 64029 --home-dir /var/spool/munge --no-create-home --shell /bin/false munge @@ -63,15 +67,24 @@ RUN mkdir /run/munge && chown munge:munge /run/munge # Copy the built slurm binaries from the builder stage COPY --from=builder /opt/slurm /opt/slurm - -FROM daemon_base as slurmctld - # Default configuration options in supervisord.conf that can be overridden at runtime ENV MUNGED_ARGS= ENV SLURMCTLD_ARGS= # This allows the user to use a pre-existing munge key ENV MUNGE_KEY_IMPORT_PATH=/etc/munge/munge.imported.key +COPY daemon-base/supervisord.conf /etc/supervisord.conf + +# Convenience scripts +COPY daemon-base/prefix-output.sh /opt/prefix-output.sh +RUN chmod +x /opt/prefix-output.sh + +ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"] + + +# MARK: slurmctld +FROM daemon-base as slurmctld + # Set up for the runtime agent RUN mkdir /etc/slurm /etc/runtime_config && touch /etc/runtime_config/passwd /etc/runtime_config/group RUN cp /etc/passwd /etc/passwd.system && cp /etc/group /etc/group.system @@ -79,25 +92,18 @@ RUN cp /etc/passwd /etc/passwd.system && cp /etc/group /etc/group.system # Copy configuration files and scripts COPY slurmctld/runtime-agent.sh /opt/runtime-agent.sh RUN chmod +x /opt/runtime-agent.sh -COPY prefix-output.sh /opt/prefix-output.sh -RUN chmod +x /opt/prefix-output.sh COPY slurmctld/entrypoint.sh /opt/entrypoint.sh RUN chmod +x /opt/entrypoint.sh -COPY slurmctld/supervisord.conf /etc/supervisord.conf +COPY slurmctld/supervisor-conf/ /etc/supervisor/conf.d/ ENTRYPOINT ["/opt/entrypoint.sh"] -FROM daemon_base as slurmdbd +# MARK: slurmdbd +FROM daemon-base as slurmdbd RUN apt update && apt install -y libmysqlclient21 -# Default configuration options in supervisord.conf that can be overridden at runtime -ENV MUNGED_ARGS= -ENV SLURMDBD_ARGS= -# This allows the user to use a pre-existing munge key -ENV MUNGE_KEY_IMPORT_PATH=/etc/munge/munge.imported.key - # Set up for the runtime agent RUN mkdir /etc/slurm /etc/runtime_config /etc/slurmdbd_config && touch /etc/runtime_config/passwd /etc/runtime_config/group RUN cp /etc/passwd /etc/passwd.system && cp /etc/group /etc/group.system @@ -105,8 +111,4 @@ RUN cp /etc/passwd /etc/passwd.system && cp /etc/group /etc/group.system # Copy configuration files and scripts COPY slurmdbd/runtime-agent.sh /opt/runtime-agent.sh RUN chmod +x /opt/runtime-agent.sh -COPY prefix-output.sh /opt/prefix-output.sh -RUN chmod +x /opt/prefix-output.sh -COPY slurmdbd/supervisord.conf /etc/supervisord.conf - -ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"] +COPY slurmdbd/supervisor-conf/ /etc/supervisor/conf.d/ diff --git a/README.md b/README.md index f29c8cf..5e7a777 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This repo contains scripts to build SLURM from source for the [WATcloud][watclou ## Packages -- [slurmdbd and slurmctld Docker images](https://github.com/WATonomous/slurm-dist/pkgs/container/slurm-dist) +- [Docker images (slurmdbd, slurmctld, etc.)](https://github.com/WATonomous/slurm-dist/pkgs/container/slurm-dist) - [SLURM binaries compiled for Ubuntu 22.04](https://github.com/WATonomous/slurm-dist/releases) [watcloud]: https://cloud.watonomous.ca/ diff --git a/prefix-output.sh b/daemon-base/prefix-output.sh similarity index 100% rename from prefix-output.sh rename to daemon-base/prefix-output.sh diff --git a/slurmdbd/supervisord.conf b/daemon-base/supervisord.conf similarity index 60% rename from slurmdbd/supervisord.conf rename to daemon-base/supervisord.conf index aa6eb9f..8d56b49 100644 --- a/slurmdbd/supervisord.conf +++ b/daemon-base/supervisord.conf @@ -22,21 +22,5 @@ stdout_logfile_maxbytes=0 redirect_stderr=true priority=100 -[program:runtime_agent] -command=/opt/prefix-output.sh /opt/runtime-agent.sh -autostart=true -autorestart=true -stdout_logfile=/dev/fd/1 -stdout_logfile_maxbytes=0 -redirect_stderr=true -priority=100 - -[program:slurmdbd] -command=/opt/prefix-output.sh /opt/slurm/sbin/slurmdbd -D %(ENV_SLURMDBD_ARGS)s -autostart=true -autorestart=true -user=slurm -stdout_logfile=/dev/fd/1 -stdout_logfile_maxbytes=0 -redirect_stderr=true -priority=150 +[include] +files = /etc/supervisor/conf.d/*.conf diff --git a/slurmctld/supervisor-conf/slurmctld.conf b/slurmctld/supervisor-conf/slurmctld.conf new file mode 100644 index 0000000..9c6fe52 --- /dev/null +++ b/slurmctld/supervisor-conf/slurmctld.conf @@ -0,0 +1,18 @@ +[program:runtime_agent] +command=/opt/prefix-output.sh /opt/runtime-agent.sh +autostart=true +autorestart=true +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 +redirect_stderr=true +priority=100 + +[program:slurmctld] +command=/opt/prefix-output.sh /opt/slurm/sbin/slurmctld -D %(ENV_SLURMCTLD_ARGS)s +autostart=true +autorestart=true +user=slurm +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 +redirect_stderr=true +priority=150 diff --git a/slurmctld/supervisord.conf b/slurmctld/supervisord.conf deleted file mode 100644 index 23d2027..0000000 --- a/slurmctld/supervisord.conf +++ /dev/null @@ -1,42 +0,0 @@ -[supervisord] -nodaemon=true -user=root -logfile=/var/log/supervisor/supervisord.log - -[unix_http_server] -file=/var/run/supervisor.sock - -[rpcinterface:supervisor] -supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface - -[supervisorctl] -serverurl=unix:///var/run/supervisor.sock - -[program:munge] -command=/opt/prefix-output.sh /usr/bin/bash -c 'if [ -s "%(ENV_MUNGE_KEY_IMPORT_PATH)s" ]; then cp "%(ENV_MUNGE_KEY_IMPORT_PATH)s" /etc/munge/munge.key; fi; /usr/sbin/munged --foreground %(ENV_MUNGED_ARGS)s' -autostart=true -autorestart=true -user=munge -stdout_logfile=/dev/fd/1 -stdout_logfile_maxbytes=0 -redirect_stderr=true -priority=100 - -[program:runtime_agent] -command=/opt/prefix-output.sh /opt/runtime-agent.sh -autostart=true -autorestart=true -stdout_logfile=/dev/fd/1 -stdout_logfile_maxbytes=0 -redirect_stderr=true -priority=100 - -[program:slurmctld] -command=/opt/prefix-output.sh /opt/slurm/sbin/slurmctld -D %(ENV_SLURMCTLD_ARGS)s -autostart=true -autorestart=true -user=slurm -stdout_logfile=/dev/fd/1 -stdout_logfile_maxbytes=0 -redirect_stderr=true -priority=150 diff --git a/slurmdbd/supervisor-conf/slurmdbd.conf b/slurmdbd/supervisor-conf/slurmdbd.conf new file mode 100644 index 0000000..4a155ab --- /dev/null +++ b/slurmdbd/supervisor-conf/slurmdbd.conf @@ -0,0 +1,18 @@ +[program:runtime_agent] +command=/opt/prefix-output.sh /opt/runtime-agent.sh +autostart=true +autorestart=true +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 +redirect_stderr=true +priority=100 + +[program:slurmdbd] +command=/opt/prefix-output.sh /opt/slurm/sbin/slurmdbd -D %(ENV_SLURMDBD_ARGS)s +autostart=true +autorestart=true +user=slurm +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 +redirect_stderr=true +priority=150