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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
HPC_JEKYLL_CONFIG=_includes/snippets_library/BSU_Borah_slurm/_config_options.yml
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ Gemfile.lock
scratch/
.vendor
.bundle
.bundle-pr
.pr_builds
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM ruby:3.3-bullseye

# System deps for Jekyll & common plugins
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git build-essential nodejs && \
rm -rf /var/lib/apt/lists/*

WORKDIR /work

# Local (project) gem install path for caching
ENV BUNDLE_PATH=/work/vendor/bundle \
BUNDLE_JOBS=4 \
BUNDLE_RETRY=3

# Ensure a recent Bundler is present
RUN gem install bundler

# Tiny entrypoint with helper commands
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

ENTRYPOINT ["entrypoint.sh"]
CMD ["help"]

17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ This lesson teaches the basics of interacting with high-performance computing

## Using this material

Docker setup for BSU research computing

1. Build the image
```bash
docker compose build
```

2. Build PR files into `./.pr_builds/pr-<num>`
```bash
PR=4 docker compose run --rm --service-ports pr-check
```

3. Build PR and start webserver for it
```bash
PR=4 docker compose run --rm --service-ports pr-serve
```

NOTE: This is _not_ Carpentries boilerplate! Please read carefully.

1. Follow the instructions found in The Carpentries' [example lesson][ex-lesson]
Expand Down
58 changes: 58 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
services:
dev:
build: .
image: hpc-intro-jekyll
working_dir: /work
volumes:
- .:/work
- ./.bundle:/work/vendor/bundle # cache gems for faster subsequent runs
environment:
# You MUST set this (see README in the repo)
# e.g. HPC_JEKYLL_CONFIG=_includes/snippets_library/YourInst_YourCluster_Slurm/_config_options.yml
HPC_JEKYLL_CONFIG: ${HPC_JEKYLL_CONFIG}
JEKYLL_ENV: development
ports:
- "4000:4000"
- "35729:35729"
command: serve

build:
build: .
image: hpc-intro-jekyll
working_dir: /work
volumes:
- .:/work
- ./.bundle:/work/vendor/bundle
environment:
HPC_JEKYLL_CONFIG: ${HPC_JEKYLL_CONFIG}
JEKYLL_ENV: production
command: build

pr-check:
build: .
image: hpc-intro-jekyll
environment:
REPO_URL: https://github.com/bsurc/hpc-intro.git
# Run with: PR=123 docker compose run --rm pr-check
PR: ${PR}
HPC_JEKYLL_CONFIG: ${HPC_JEKYLL_CONFIG}
volumes:
- ./.pr_builds:/output # built PR sites land here: ./.pr_builds/pr-<num>
- ./.bundle-pr:/work/vendor/bundle # separate cache for PR builds
command: pr


pr-serve:
build: .
image: hpc-intro-jekyll
environment:
REPO_URL: https://github.com/bsurc/hpc-intro.git
PR: ${PR}
HPC_JEKYLL_CONFIG: ${HPC_JEKYLL_CONFIG}
PORT: ${PORT:-4000}
LR_PORT: ${LR_PORT:-35729}
# publish whatever PORT/LR_PORT you choose at runtime
ports:
- "${PORT:-4000}:${PORT:-4000}"
- "${LR_PORT:-35729}:${LR_PORT:-35729}"
command: pr-serve
84 changes: 84 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env bash
set -euo pipefail

require_config() {
if [[ -z "${HPC_JEKYLL_CONFIG:-}" ]]; then
echo "ERROR: HPC_JEKYLL_CONFIG is not set."
echo "Set it to a snippet config path (see _includes/snippets_library/.../_config_options.yml)."
exit 2
fi
export HPC_JEKYLL_CONFIG
}

case "${1:-help}" in
serve)
require_config
if [[ -f Gemfile ]]; then bundle install; fi
exec bundle exec jekyll serve \
--host 0.0.0.0 --port "${PORT:-4000}" \
--livereload --livereload-port "${LR_PORT:-35729}"
;;

build)
require_config
if [[ -f Gemfile ]]; then bundle install; fi
exec bundle exec jekyll build -d "${DEST:-/work/_site}"
;;

pr)
require_config
: "${PR:?Set PR=<number> to build a pull request}"
: "${REPO_URL:?Set REPO_URL to the git URL of the repo}"
SRC="${SRC_DIR:-/tmp/src}"
rm -rf "$SRC"
echo "Cloning $REPO_URL ..."
git clone --depth=1 "$REPO_URL" "$SRC"
cd "$SRC"
echo "Fetching PR #$PR ..."
git fetch origin "pull/${PR}/head:pr-${PR}"
git checkout "pr-${PR}"
bundle install
bundle exec jekyll build -d "/output/pr-${PR}"
echo "Built PR #$PR to /output/pr-${PR}"
;;

pr-serve)
require_config
: "${PR:?Set PR=<number> to serve a pull request}"
: "${REPO_URL:?Set REPO_URL to the git URL of the repo}"
PORT="${PORT:-4000}"
LR_PORT="${LR_PORT:-35729}"
SRC="${SRC_DIR:-/tmp/src}"
rm -rf "$SRC"
echo "Cloning $REPO_URL ..."
git clone --depth=1 "$REPO_URL" "$SRC"
cd "$SRC"
echo "Fetching PR #$PR ..."
git fetch origin "pull/${PR}/head:pr-${PR}"
git checkout "pr-${PR}"
bundle install
exec bundle exec jekyll serve \
--host 0.0.0.0 --port "$PORT" \
--livereload --livereload-port "$LR_PORT"
;;

help|--help|-h)
cat <<'EOF'
Usage: entrypoint.sh [serve|build|pr]

serve - bundle install and run `jekyll serve` (ports 4000 & 35729 exposed)
build - bundle install and run `jekyll build` into /work/_site (or DEST)
pr - clone upstream repo, checkout PR=<num>, and build to /output/pr-<num>

Env:
HPC_JEKYLL_CONFIG REQUIRED: path to _config_options.yml from snippets library
PR For 'pr' command, PR number to build
REPO_URL For 'pr' command, git URL (defaults set in compose)
DEST Build destination (default varies by command)
EOF
;;

*)
echo "Unknown command: $1"; exit 1;;
esac

Loading