Skip to content

refactor: modularize setup scripts and streamline Docker login#2587

Merged
crivetimihai merged 1 commit intomainfrom
jps-rocky-ii
Jan 31, 2026
Merged

refactor: modularize setup scripts and streamline Docker login#2587
crivetimihai merged 1 commit intomainfrom
jps-rocky-ii

Conversation

@jonpspri
Copy link
Copy Markdown
Collaborator

🔗 Related Issue

N/A - Internal improvement


📝 Summary

Refactors the monolithic Rocky Linux setup script into a modular, multi-distribution installer supporting Ubuntu, Debian, Rocky Linux, RHEL, CentOS, AlmaLinux, and Fedora. Streamlines the Docker login flow and adds deployment documentation.

Key changes:

  • New main entry point: scripts/contextforge-setup.sh
  • Modular library structure: scripts/lib/common.sh, debian.sh, rhel.sh
  • Removes old scripts/rocky-contextforge-setup-script.sh
  • Adds Docker Compose deployment documentation

🏷️ Type of Change

  • Bug fix
  • Feature / Enhancement
  • Documentation
  • Refactor
  • Chore (deps, CI, tooling)
  • Other (describe below)

🧪 Verification

Check Command Status
Lint suite make lint N/A (bash scripts)
Unit tests make test N/A (bash scripts)
Coverage ≥ 90% make coverage N/A

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • Tests added/updated for changes
  • Documentation updated (if applicable)
  • No secrets or credentials committed

📓 Notes

The modular structure improves maintainability by:

  • Separating distribution-specific logic (Debian vs RHEL families)
  • Centralizing common functions (Docker install, git clone, compose operations)
  • Supporting multiple CLI flags: --skip-start, --skip-docker-login, -y/--yes

Copilot AI review requested due to automatic review settings January 30, 2026 11:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the previous monolithic Rocky Linux setup script into a modular, multi-distribution installer and updates deployment documentation to describe the new setup flow.

Changes:

  • Introduces scripts/contextforge-setup.sh as the new entrypoint with shared helpers in scripts/lib/common.sh and OS-specific modules in scripts/lib/debian.sh and scripts/lib/rhel.sh.
  • Removes the legacy Rocky-only setup script.
  • Adds Docker Compose deployment documentation for the automated setup script.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
scripts/rocky-contextforge-setup-script.sh Removes the old Rocky-only installer script.
scripts/contextforge-setup.sh Adds new multi-distro setup entrypoint and CLI flags.
scripts/lib/common.sh Adds shared OS detection + Docker login helpers + common setup steps.
scripts/lib/debian.sh Adds Debian/Ubuntu-family package + Docker install logic.
scripts/lib/rhel.sh Adds RHEL-family package + Docker install logic and podman conflict handling.
docs/docs/deployment/compose.md Documents the new automated setup script and usage.
.gitignore Adds an exception rule related to scripts/lib.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +60 to +66
./contextforge-setup.sh -y --skip-start

# Automated install with Docker Hub credentials
DOCKER_USERNAME=myuser DOCKER_PASSWORD=mypass ./contextforge-setup.sh -y

# Install to custom directory
./contextforge-setup.sh ~/my-contextforge
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Examples section the script is invoked as ./contextforge-setup.sh, but the Quick Start above uses ./scripts/contextforge-setup.sh and the script lives under scripts/. These example commands won’t work from the repo root as written; please update them to the correct path (or clarify the expected working directory).

Suggested change
./contextforge-setup.sh -y --skip-start
# Automated install with Docker Hub credentials
DOCKER_USERNAME=myuser DOCKER_PASSWORD=mypass ./contextforge-setup.sh -y
# Install to custom directory
./contextforge-setup.sh ~/my-contextforge
./scripts/contextforge-setup.sh -y --skip-start
# Automated install with Docker Hub credentials
DOCKER_USERNAME=myuser DOCKER_PASSWORD=mypass ./scripts/contextforge-setup.sh -y
# Install to custom directory
./scripts/contextforge-setup.sh ~/my-contextforge

Copilot uses AI. Check for mistakes.
Comment on lines +56 to +79
# Add Docker's official GPG key
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Determine the correct Docker repo based on distro
local docker_repo
case "$DISTRO_ID" in
ubuntu)
docker_repo="https://download.docker.com/linux/ubuntu"
;;
debian)
docker_repo="https://download.docker.com/linux/debian"
;;
*)
# For derivatives, try Ubuntu repo
docker_repo="https://download.docker.com/linux/ubuntu"
log_warn "Using Ubuntu Docker repo for $DISTRO_ID"
;;
esac

# Add the repository to apt sources
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] $docker_repo \
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Docker GPG key is always fetched from the Ubuntu URL, even when DISTRO_ID is debian. Since the repo URL switches between linux/ubuntu and linux/debian, the key URL should match the selected repo base to avoid potential key/repo mismatches.

Suggested change
# Add Docker's official GPG key
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
# Determine the correct Docker repo based on distro
local docker_repo
case "$DISTRO_ID" in
ubuntu)
docker_repo="https://download.docker.com/linux/ubuntu"
;;
debian)
docker_repo="https://download.docker.com/linux/debian"
;;
*)
# For derivatives, try Ubuntu repo
docker_repo="https://download.docker.com/linux/ubuntu"
log_warn "Using Ubuntu Docker repo for $DISTRO_ID"
;;
esac
# Add the repository to apt sources
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] $docker_repo \
# Determine the correct Docker repo base (and matching GPG key URL) based on distro
local docker_repo_base
case "$DISTRO_ID" in
ubuntu)
docker_repo_base="https://download.docker.com/linux/ubuntu"
;;
debian)
docker_repo_base="https://download.docker.com/linux/debian"
;;
*)
# For derivatives, try Ubuntu repo
docker_repo_base="https://download.docker.com/linux/ubuntu"
log_warn "Using Ubuntu Docker repo for $DISTRO_ID"
;;
esac
# Add Docker's official GPG key
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL "$docker_repo_base/gpg" | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
# Add the repository to apt sources
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] $docker_repo_base \

Copilot uses AI. Check for mistakes.
Comment on lines +15 to +21
log_info "Continuing in non-interactive mode..."
else
read -p "Continue anyway? [y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check_os can return a non-zero status even when the user chooses to continue on a derivative distro (Linux Mint/Pop!_OS). In the interactive path, the last executed command is the [[ ! $REPLY =~ ... ]] test, which returns 1 when the reply is yes; with set -e in the main script, that will abort the installer. Add an explicit return 0 after a successful confirmation (and similarly ensure all non-failing branches end with a zero exit status).

Suggested change
log_info "Continuing in non-interactive mode..."
else
read -p "Continue anyway? [y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
log_info "Continuing in non-interactive mode..."
return 0
else
read -p "Continue anyway? [y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
return 0

Copilot uses AI. Check for mistakes.
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Fedora (experimental) branch, check_os may return a non-zero status even when the user chooses to continue: the last executed command can be the [[ ! $REPLY =~ ... ]] test, which returns 1 on a 'yes' reply. With set -e in the main script, that would abort the installer. Add an explicit return 0 after the confirmation/continue path so the function reliably succeeds when continuing.

Suggested change
fi
fi
return 0

Copilot uses AI. Check for mistakes.
@jonpspri jonpspri marked this pull request as draft January 30, 2026 15:06
@jonpspri jonpspri force-pushed the jps-rocky-ii branch 2 times, most recently from 8ee02c9 to b5d4f1b Compare January 30, 2026 15:22
@jonpspri jonpspri marked this pull request as ready for review January 30, 2026 16:58
@jonpspri jonpspri requested a review from gcgoncalves January 30, 2026 16:58
@crivetimihai crivetimihai self-assigned this Jan 31, 2026
- New main entry point: scripts/contextforge-setup.sh
- Modular library structure: scripts/lib/common.sh, debian.sh, rhel.sh
- Removes old scripts/rocky-contextforge-setup-script.sh
- Renames scripts/ubuntu-contextforge-setup-script.sh to lib/common.sh
- Adds --skip-docker-login flag and DOCKER_* env var support
- Adds Docker Compose deployment documentation

Signed-off-by: Jonathan Springer <jps@s390x.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
@crivetimihai
Copy link
Copy Markdown
Member

Review Complete ✅

Rebased on main and made the following adjustments:

Changes Made

  1. Rebased on main - Clean rebase with no conflicts

  2. Fixed commit message format - Updated to follow conventional commits:

    refactor(scripts): modularize setup scripts and streamline Docker login
    
    - New main entry point: scripts/contextforge-setup.sh
    - Modular library structure: scripts/lib/common.sh, debian.sh, rhel.sh
    - Removes old scripts/rocky-contextforge-setup-script.sh
    - Renames scripts/ubuntu-contextforge-setup-script.sh to lib/common.sh
    - Adds --skip-docker-login flag and DOCKER_* env var support
    - Adds Docker Compose deployment documentation
    

Review Notes

Check Result
Shellcheck ✅ Pass (info-level only)
Bash syntax validation ✅ Valid
Security review ✅ Password handling uses printenv + --password-stdin
Logic review ✅ OS detection and modular sourcing correct
Documentation ✅ Comprehensive

Ready for merge.

@crivetimihai crivetimihai merged commit 96bb042 into main Jan 31, 2026
39 checks passed
@crivetimihai crivetimihai deleted the jps-rocky-ii branch January 31, 2026 15:17
@crivetimihai crivetimihai added this to the Release 1.0.0-RC1 milestone Jan 31, 2026
hughhennelly pushed a commit to hughhennelly/mcp-context-forge that referenced this pull request Feb 8, 2026
…in (IBM#2587)

- New main entry point: scripts/contextforge-setup.sh
- Modular library structure: scripts/lib/common.sh, debian.sh, rhel.sh
- Removes old scripts/rocky-contextforge-setup-script.sh
- Renames scripts/ubuntu-contextforge-setup-script.sh to lib/common.sh
- Adds --skip-docker-login flag and DOCKER_* env var support
- Adds Docker Compose deployment documentation

Signed-off-by: Jonathan Springer <jps@s390x.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Signed-off-by: hughhennnelly <hughhennelly06@gmail.com>
kcostell06 pushed a commit to kcostell06/mcp-context-forge that referenced this pull request Feb 24, 2026
…in (IBM#2587)

- New main entry point: scripts/contextforge-setup.sh
- Modular library structure: scripts/lib/common.sh, debian.sh, rhel.sh
- Removes old scripts/rocky-contextforge-setup-script.sh
- Renames scripts/ubuntu-contextforge-setup-script.sh to lib/common.sh
- Adds --skip-docker-login flag and DOCKER_* env var support
- Adds Docker Compose deployment documentation

Signed-off-by: Jonathan Springer <jps@s390x.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants