diff --git a/.devcontainer/vscode-init/02-download-extensions.sh b/.devcontainer/vscode-init/02-download-extensions.sh index 38e7b83..134f6f4 100755 --- a/.devcontainer/vscode-init/02-download-extensions.sh +++ b/.devcontainer/vscode-init/02-download-extensions.sh @@ -10,7 +10,7 @@ set -e # of the extension and its functionality gets inherited by devcontainers. EXTENSIONS_FILE="extensions-to-download.txt" -DOWNLOAD_DIR="/opt/vscode-extensions" +DOWNLOAD_DIR=${1:-"/opt/vscode-extensions"} SUCCESSFUL_DOWNLOADS=() mkdir -p "${DOWNLOAD_DIR}" diff --git a/.devcontainer/vscode-init/extensions-to-install.txt b/.devcontainer/vscode-init/extensions-to-install.txt index 9fb91ff..ad05bce 100644 --- a/.devcontainer/vscode-init/extensions-to-install.txt +++ b/.devcontainer/vscode-init/extensions-to-install.txt @@ -2,10 +2,8 @@ # These extensions will be enabled for all users of the devcontainer. # One extension ID per line. charliermarsh.ruff -Continue.continue --pre-release DavidAnson.vscode-markdownlint eamodio.gitlens -# The marimo extension has been removed from the marketplace whilst it is being rewritten. marimo-team.vscode-marimo mechatroner.rainbow-csv ms-ossdata.vscode-pgsql --pre-release @@ -15,5 +13,4 @@ ms-toolsai.jupyter #openai.chatgpt qwenlm.qwen-code-vscode-ide-companion REditorSupport.r -REditorSupport.r-syntax yzhang.markdown-all-in-one \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 4af3251..8f04168 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,26 +6,21 @@ ARG VSCODE_COMMIT=bf9252a2fb45be6893dd8870c0bf37e2e1766d61 ENV VSCODE_COMMIT=${VSCODE_COMMIT} -# Copy and run VS Code installation files -COPY .devcontainer/vscode-init /opt/vscode-init - -# Copy Qwen settings -COPY .devcontainer/qwen-settings.json /root/.qwen/settings.json - -# Copy Codex config -COPY .devcontainer/codex-config.toml /root/.codex/config.toml - -# Copy Continue Dev config -COPY .devcontainer/continue-config.yaml /root/.continue/config.yaml -COPY .devcontainer/continue.env /root/.continue/.env - -# Copy scripts folder to /opt/scripts (accessible at runtime) -COPY scripts /opt/scripts - -RUN cd /opt/vscode-init \ - && ./00-install-vscode-server.sh ${VSCODE_COMMIT} \ - && ./01-install-extensions.sh ${VSCODE_COMMIT} \ - && ./02-download-extensions.sh +# Copy custom scripts and installation files +COPY .devcontainer /opt/.devcontainer + +# Copy devcontainerctl folder to /opt/devcontainerctl (accessible at runtime) +COPY devcontainerctl /opt/devcontainerctl + +# Run VS Code installation files & copy configurations +RUN cd /opt/.devcontainer/vscode-init \ + && /opt/.devcontainer/vscode-init/00-install-vscode-server.sh ${VSCODE_COMMIT} \ + && /opt/.devcontainer/vscode-init/01-install-extensions.sh ${VSCODE_COMMIT} \ + && /opt/.devcontainer/vscode-init/02-download-extensions.sh /opt/vscode-extensions \ + && mkdir -p /root/.qwen && cp /opt/.devcontainer/qwen-settings.json /root/.qwen/settings.json \ + && mkdir -p /root/.codex && cp /opt/.devcontainer/codex-config.toml /root/.codex/config.toml \ + && mkdir -p /root/.continue && cp /opt/.devcontainer/continue-config.yaml /root/.continue/config.yaml \ + && cp /opt/.devcontainer/continue.env /root/.continue/.env WORKDIR /workspace diff --git a/README.md b/README.md index 9d74dfc..6769a2d 100644 --- a/README.md +++ b/README.md @@ -66,10 +66,10 @@ ces-pull a a ghcr.io/smartdatafoundry/devcontainer:latest # 2. Extract the setup scripts podman run --rm -v $HOME:$HOME -w $HOME \ ghcr.io/smartdatafoundry/devcontainer:latest \ - cp -r /opt/scripts $HOME/devcontainer-scripts + cp -r /opt/devcontainerctl $HOME/devcontainerctl # 3. Run the setup script (one-time setup) -cd $HOME/devcontainer-scripts +cd $HOME/devcontainerctl ./setup.sh # 4. Start your devcontainer @@ -106,7 +106,7 @@ For detailed manual setup instructions, see the **[SDF TRE Setup Guide](docs/SDF |-------|-----------| | SDF TRE usage | [`docs/SDF_TRE_SETUP.md`](docs/SDF_TRE_SETUP.md) | | Full container internals | [`docs/DEVCONTAINER.md`](docs/DEVCONTAINER.md) | -| Setup scripts | [`scripts/`](scripts/) directory | +| Setup scripts | [`devcontainerctl/`](devcontainerctl/) directory | | Reusable publish workflow | [`docs/BUILD_PUBLISH_CONTAINER.md`](docs/BUILD_PUBLISH_CONTAINER.md) | | Dev Container Specification | https://containers.dev | @@ -119,7 +119,7 @@ For detailed manual setup instructions, see the **[SDF TRE Setup Guide](docs/SDF - **Shell**: Zsh with Oh My Zsh (via common-utils feature) - **Quarto**: Document publishing platform (latest version) - **Marimo**: Markdown presentation tool, alternative to Jupyter Notebooks -- **User Setup Scripts**: Automated deployment and management tools ([`scripts/`](scripts/)) +- **User Setup Scripts**: Automated deployment and management tools ([`devcontainerctl/`](devcontainerctl/)) - **VS Code Extensions (curated)**: - Continue (AI assistant) - Black (Python formatting) diff --git a/scripts/devcontainerctl b/devcontainerctl/devcontainerctl similarity index 100% rename from scripts/devcontainerctl rename to devcontainerctl/devcontainerctl diff --git a/scripts/setup.sh b/devcontainerctl/setup.sh similarity index 70% rename from scripts/setup.sh rename to devcontainerctl/setup.sh index 9319da2..bf757b9 100644 --- a/scripts/setup.sh +++ b/devcontainerctl/setup.sh @@ -11,11 +11,12 @@ NC='\033[0m' # No Color echo -e "${GREEN}DevContainer Setup Script${NC}" echo "================================" -# Define paths +# Define files & paths SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" SCRIPT_SOURCE="$SCRIPT_DIR/devcontainerctl" SYMLINK_TARGET="$HOME/bin/devcontainerctl" CRON_COMMAND="0 8 * * * $SYMLINK_TARGET sync" +EXTENSION_FILE="/safe_data/shared/vscode-extensions/ms-vscode-remote.remote-containers.vsix" # Check if source script exists if [ ! -f "$SCRIPT_SOURCE" ]; then @@ -23,6 +24,18 @@ if [ ! -f "$SCRIPT_SOURCE" ]; then exit 1 fi +# Install VS Code remote containers extensions if code command is available +if command -v code >/dev/null 2>&1; then + echo -e "${YELLOW}Installing VS Code remote containers extension...${NC}" + code --install-extension $EXTENSION_FILE || { + echo -e "${RED}Failed to install remote containers extension${NC}" + exit 1 + } +else + echo -e "${RED}VS Code command 'code' not found. Skipping extension installation.${NC}" + exit 1 +fi + # Create ~/bin directory if it doesn't exist if [ ! -d "$HOME/bin" ]; then echo -e "${YELLOW}Creating $HOME/bin directory...${NC}" @@ -32,7 +45,7 @@ fi # Create symlink if [ -L "$SYMLINK_TARGET" ]; then echo -e "${YELLOW}Symlink already exists at $SYMLINK_TARGET${NC}" - echo "Removing old symlink..." + echo -e "${YELLOW}Removing old symlink...${NC}" rm "$SYMLINK_TARGET" fi @@ -42,7 +55,7 @@ ln -s "$SCRIPT_SOURCE" "$SYMLINK_TARGET" # Make sure the source script is executable if [ ! -x "$SCRIPT_SOURCE" ]; then echo -e "${YELLOW}Warning: $SCRIPT_SOURCE is not executable${NC}" - echo "You may need to run: sudo chmod +x $SCRIPT_SOURCE" + echo -e "${YELLOW}You may need to run: sudo chmod +x $SCRIPT_SOURCE${NC}" fi # Add ~/bin to PATH if not already present @@ -75,9 +88,9 @@ echo "" echo "================================" echo -e "${GREEN}Setup Complete!${NC}" echo "" -echo "Verification:" -echo " Symlink: $(ls -la $SYMLINK_TARGET 2>/dev/null || echo 'Not found')" -echo " Cron job:" -crontab -l | grep "devcontainerctl sync" || echo " Not found" +echo -e "${GREEN}Verification:${NC}" +echo -e "${GREEN} Symlink: $(ls -la $SYMLINK_TARGET 2>/dev/null || echo 'Not found')${NC}" +echo -e "${GREEN} Cron job:${NC}" +crontab -l | grep "devcontainerctl sync" || echo -e "${GREEN} Not found${NC}" echo "" echo -e "${YELLOW}Note: You may need to restart your shell or run 'source ~/.bashrc'${NC}" \ No newline at end of file diff --git a/docs/DEVCONTAINER.md b/docs/DEVCONTAINER.md index 71df145..34ce605 100644 --- a/docs/DEVCONTAINER.md +++ b/docs/DEVCONTAINER.md @@ -75,13 +75,13 @@ This dev container includes: * **Marimo**: Alternative interactive notebook/presentation tool * **VS Code Server**: Pre-installed (pin via tag families) * **VS Code Extensions**: Curated list (see [`.devcontainer/vscode-init/extensions-to-install.txt`](.devcontainer/vscode-init/extensions-to-install.txt)) -* **User Setup Scripts**: Automated deployment and management tools (at `/opt/scripts/` in container) +* **User Setup Scripts**: Automated deployment and management tools (at `/opt/devcontainerctl/` in container) ### User Setup Scripts -The container includes scripts in [`/opt/scripts/`](../scripts/) to simplify deployment and management: +The container includes scripts in [`/opt/devcontainerctl/`](../devcontainerctl/) to simplify deployment and management: -#### [`scripts/devcontainerctl`](scripts/devcontainerctl) +#### [`devcontainerctl/devcontainerctl`](../devcontainerctl/devcontainerctl) A comprehensive container lifecycle management script that provides: **Features:** @@ -112,7 +112,7 @@ devcontainerctl stop # Stop container devcontainerctl remove # Remove container ``` -#### [`scripts/setup.sh`](scripts/setup.sh) +#### [`devcontainerctl/setup.sh`](../devcontainerctl/setup.sh) One-time setup script that configures your environment: **What it does:** @@ -120,16 +120,17 @@ One-time setup script that configures your environment: - Creates symlink to `devcontainerctl` in `~/bin` - Adds `~/bin` to PATH in `~/.bashrc` - Configures daily cron job (8:00 AM) to sync images using `devcontainerctl sync` +- Installs VS Code remote extensions for devcontainer enablement **Usage:** ```bash # Extract scripts from container first podman run --rm -v $HOME:$HOME -w $HOME \ ghcr.io/smartdatafoundry/devcontainer:latest \ - cp -r /opt/scripts $HOME/devcontainer-scripts + cp -r /opt/devcontainerctl $HOME/devcontainerctl # Run setup -cd $HOME/devcontainer-scripts +cd $HOME/devcontainerctl ./setup.sh ``` @@ -186,7 +187,7 @@ This keeps maintenance simple: update the default by editing a single line in [` │ ├── build-devcontainer.yml # Dev container build workflow │ ├── build-publish-container.yml # Container publishing workflow │ └── update-vscode.yml # VS Code version update workflow -├── scripts/ # User deployment scripts +├── devcontainerctl/ # User deployment scripts │ ├── devcontainerctl # Container management script │ └── setup.sh # One-time setup script ├── assets/ # Documentation assets diff --git a/docs/SDF_TRE_SETUP.md b/docs/SDF_TRE_SETUP.md index 4793689..b2d77ea 100644 --- a/docs/SDF_TRE_SETUP.md +++ b/docs/SDF_TRE_SETUP.md @@ -15,10 +15,10 @@ ces-pull a a ghcr.io/smartdatafoundry/devcontainer:latest # 2. Extract the setup scripts podman run --rm -v $HOME:$HOME -w $HOME \ ghcr.io/smartdatafoundry/devcontainer:latest \ - cp -r /opt/scripts $HOME/devcontainer-scripts + cp -r /opt/devcontainerctl $HOME/devcontainerctl # 3. Run the one-time setup -cd $HOME/devcontainer-scripts +cd $HOME/devcontainerctl ./setup.sh # 4. Start your devcontainer @@ -53,7 +53,7 @@ The devcontainer includes scripts that automate deployment and management in the After extracting the scripts (see Quick Start above), run the setup script: ```bash -cd $HOME/devcontainer-scripts +cd $HOME/devcontainerctl ./setup.sh ```