refactor: modularize setup scripts and streamline Docker login#2587
refactor: modularize setup scripts and streamline Docker login#2587crivetimihai merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
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.shas the new entrypoint with shared helpers inscripts/lib/common.shand OS-specific modules inscripts/lib/debian.shandscripts/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.
docs/docs/deployment/compose.md
Outdated
| ./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 |
There was a problem hiding this comment.
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).
| ./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 |
scripts/lib/debian.sh
Outdated
| # 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 \ |
There was a problem hiding this comment.
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.
| # 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 \ |
| 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 |
There was a problem hiding this comment.
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).
| 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 |
| if [[ ! $REPLY =~ ^[Yy]$ ]]; then | ||
| exit 1 | ||
| fi | ||
| fi |
There was a problem hiding this comment.
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.
| fi | |
| fi | |
| return 0 |
8ee02c9 to
b5d4f1b
Compare
- 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>
b5d4f1b to
c343ed5
Compare
Review Complete ✅Rebased on Changes Made
Review Notes
Ready for merge. |
…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>
…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>
🔗 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:
scripts/contextforge-setup.shscripts/lib/common.sh,debian.sh,rhel.shscripts/rocky-contextforge-setup-script.sh🏷️ Type of Change
🧪 Verification
make lintmake testmake coverage✅ Checklist
make black isort pre-commit)📓 Notes
The modular structure improves maintainability by:
--skip-start,--skip-docker-login,-y/--yes