-
Notifications
You must be signed in to change notification settings - Fork 12
feat(scripts): Add Dockerfile linting tools #28
Changes from all commits
b7c2aaa
072dbda
a896aa5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,55 +3,120 @@ set -euo pipefail | |||||
|
|
||||||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||||||
| VENV_DIR="${SCRIPT_DIR}/.venv" | ||||||
| DISABLE_VENV=false | ||||||
|
|
||||||
| echo "Setting up local development environment..." | ||||||
| while [[ $# -gt 0 ]]; do | ||||||
| case $1 in | ||||||
| --disable-venv) | ||||||
| DISABLE_VENV=true | ||||||
| shift | ||||||
| ;; | ||||||
| *) | ||||||
| echo "Unknown option: $1" >&2 | ||||||
| exit 1 | ||||||
| ;; | ||||||
| esac | ||||||
| done | ||||||
|
|
||||||
| if command -v pyenv &> /dev/null; then | ||||||
| PYTHON_VERSION="$(cat "${SCRIPT_DIR}/.python-version")" | ||||||
| echo "Python version from .python-version: ${PYTHON_VERSION}" | ||||||
| echo "Installing Python ${PYTHON_VERSION} via pyenv..." | ||||||
| pyenv install -s "${PYTHON_VERSION}" | ||||||
| # shellcheck source=deploy/002-setup/lib/common.sh | ||||||
| source "${SCRIPT_DIR}/deploy/002-setup/lib/common.sh" | ||||||
|
|
||||||
| # Preamble: Recommend devcontainer for easier setup | ||||||
| echo | ||||||
| echo "💡 RECOMMENDED: Use the Dev Container for the best experience." | ||||||
| echo | ||||||
| echo "The devcontainer includes all tools pre-configured:" | ||||||
| echo " • Azure CLI, Terraform, kubectl, helm, jq" | ||||||
| echo " • Python with all dependencies" | ||||||
| echo " • VS Code extensions for Terraform and Python" | ||||||
| echo | ||||||
| echo "To use:" | ||||||
| echo " VS Code → Reopen in Container (F1 → Dev Containers: Reopen)" | ||||||
| echo " Codespaces → Open in Codespace from GitHub" | ||||||
| echo | ||||||
| echo "If this script fails, the devcontainer is your fallback." | ||||||
| echo | ||||||
|
|
||||||
| section "Tool Verification" | ||||||
|
|
||||||
| require_tools az terraform kubectl helm jq | ||||||
| info "All required tools found" | ||||||
|
|
||||||
| section "Python Environment Setup" | ||||||
|
|
||||||
| PYTHON_VERSION="$(cat "${SCRIPT_DIR}/.python-version")" | ||||||
| info "Target Python version: ${PYTHON_VERSION}" | ||||||
|
|
||||||
| if command -v pyenv &>/dev/null; then | ||||||
| info "Installing Python ${PYTHON_VERSION} via pyenv..." | ||||||
| pyenv install -s "${PYTHON_VERSION}" | ||||||
| PYTHON_CMD="python" | ||||||
| elif command -v python3 &>/dev/null; then | ||||||
| warn "pyenv not found, using system python3" | ||||||
| PYTHON_CMD="python3" | ||||||
| else | ||||||
| fatal "Neither pyenv nor python3 found. Please install Python 3.11+" | ||||||
| fi | ||||||
|
|
||||||
| echo "Using pyenv Python $(python --version)" | ||||||
| info "Using Python: $($PYTHON_CMD --version)" | ||||||
|
|
||||||
| if [[ ! -d "${VENV_DIR}" ]]; then | ||||||
| echo "Creating virtual environment at ${VENV_DIR}..." | ||||||
| python -m venv "${VENV_DIR}" | ||||||
| if [[ "${DISABLE_VENV}" == "true" ]]; then | ||||||
| info "Virtual environment disabled, installing packages directly..." | ||||||
| else | ||||||
| echo "Virtual environment already exists at ${VENV_DIR}" | ||||||
| if [[ ! -d "${VENV_DIR}" ]]; then | ||||||
| info "Creating virtual environment at ${VENV_DIR}..." | ||||||
| $PYTHON_CMD -m venv "${VENV_DIR}" | ||||||
|
||||||
| $PYTHON_CMD -m venv "${VENV_DIR}" | |
| "$PYTHON_CMD" -m venv "${VENV_DIR}" |
Copilot
AI
Dec 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pip install commands redirect stderr to /dev/null (2>/dev/null), which completely suppresses error messages. This makes debugging difficult when installations fail. Consider redirecting stderr to a log file or at least letting critical errors through while only suppressing warnings. This would help users understand what went wrong during setup.
Copilot
AI
Dec 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the root dependencies installation, stderr is completely suppressed with 2>/dev/null, hiding potentially useful error information. Consider redirecting to a log file or showing critical errors to help with debugging installation issues.
Copilot
AI
Dec 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning message says "Run this command to activate the virtual environment" but uses the warn function which outputs to stderr with a yellow [WARN] prefix. This is more of an informational message than a warning. Consider using info instead, or use plain echo for this instructional message.
| warn "Run this command to activate the virtual environment:" | |
| info "Run this command to activate the virtual environment:" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The NGC CLI installation uses
sudo chmod u+xwhich only sets execute permission for the owner. Since the file is installed to/usr/local/bin(a system directory), it should usesudo chmod +xto ensure the executable is runnable by all users. The current approach may prevent other users from executing the ngc command.