Skip to content

Add Dockerfile and entrypoint for devcontainer setup and CI updates - #14

Open
gitricko wants to merge 14 commits into
mainfrom
dockerizeation
Open

Add Dockerfile and entrypoint for devcontainer setup and CI updates#14
gitricko wants to merge 14 commits into
mainfrom
dockerizeation

Conversation

@gitricko

Copy link
Copy Markdown
Owner

This pull request introduces a major overhaul to the devcontainer setup, switching from a slow, script-based provisioning approach to a fully pre-baked Docker image for the Hermes Codespace environment. This change dramatically reduces container startup time, ensures all heavy dependencies are pre-installed, and centralizes configuration and service startup logic. The CI workflow is also reworked to build, test, and report on the new image. The most important changes are summarized below.

Devcontainer Docker Image & Entrypoint:

  • Added a new .devcontainer/Dockerfile that pre-installs all required tools (Hermes Agent, Ollama, OmniRoute, ModelRelay, Mnemon, Cline, Claude CLI, Tailscale, etc.), copies config files, and sets up a lightweight entrypoint for runtime configuration and service startup.
  • Introduced .devcontainer/entrypoint.sh to handle all runtime setup, config placement, service startup, and first-run initialization, replacing previous post-create and start scripts.

Devcontainer Configuration Updates:

  • Updated .devcontainer/devcontainer.json to use the new Dockerfile, set container name, and remove legacy post-create and start commands, as these are now handled by the entrypoint. [1] [2]

CI/CD Pipeline Overhaul:

  • Completely restructured .github/workflows/devcontainer-ci.yml to:
    • Build and (optionally) push the Docker image to GitHub Container Registry.
    • Add smoke tests to verify all tools and configs are present in the baked image.
    • Add an integration test job using the devcontainer CLI and self-check script.
    • Add an image size report to monitor container size.

These changes ensure that the Hermes Codespace devcontainer is fast to start, reproducible, and robust, with all dependencies and configurations managed in a single place.…I workflow for image build and testing

Copilot AI review requested due to automatic review settings July 21, 2026 09:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR replaces the devcontainer’s script-based provisioning with a pre-baked Docker image + runtime entrypoint, and updates CI to build and validate that image so Codespaces startup is faster and more reproducible.

Changes:

  • Add a new baked devcontainer image (.devcontainer/Dockerfile) and runtime initialization/service launcher (.devcontainer/entrypoint.sh).
  • Update devcontainer configuration to build from the Dockerfile and remove legacy post-create/start hooks.
  • Restructure the CI workflow to build the image, run smoke checks, run an “integration” self-check, and report image size.

Reviewed changes

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

File Description
.github/workflows/devcontainer-ci.yml Reworked CI pipeline to build/test/report on the baked devcontainer image.
.devcontainer/Dockerfile New baked image build that installs required tools and config assets.
.devcontainer/entrypoint.sh New entrypoint that copies configs, starts services, and runs initialization/self-check.
.devcontainer/devcontainer.json Switch devcontainer to build from the new Dockerfile and remove legacy postCreate/postStart commands.

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

Comment on lines +69 to +73
else
echo "[$SCRIPT_NAME] Starting $name..."
setsid $cmd >> /tmp/${name}.log 2>&1 &
fi
}
# ── Place config files into $HOME (only if not already customized) ───
place_config() {
local src="$1" dst="$2"
if [ ! -f "$dst" ] || ! cmp -s "$src" "$dst" 2>/dev/null; then
Comment on lines +132 to +141
# Update mnemon plugin
rm -rf /tmp/mnemon_repo
if git clone https://github.com/gitricko/hermes-plugin-mnemon /tmp/mnemon_repo 2>/dev/null; then
if [ ! -d "$HOME/.hermes/plugins/mnemon" ] || ! diff -r -q -x __pycache__ "$HOME/.hermes/plugins/mnemon" "/tmp/mnemon_repo/mnemon" >/dev/null 2>&1; then
mkdir -p "$HOME/.hermes/plugins"
rm -rf "$HOME/.hermes/plugins/mnemon"
cp -r "/tmp/mnemon_repo/mnemon" "$HOME/.hermes/plugins/mnemon"
fi
rm -rf /tmp/mnemon_repo
fi
Comment thread .github/workflows/devcontainer-ci.yml Outdated
Comment thread .github/workflows/devcontainer-ci.yml Outdated
Comment on lines +146 to +151
- name: Install devcontainer CLI
run: npm install -g @devcontainers/cli

- name: Build devcontainer (without starting services)
run: |
docker build -f .devcontainer/Dockerfile -t hermes-codespace:test .
Comment thread .devcontainer/Dockerfile
Comment on lines +6 to +7
FROM mcr.microsoft.com/devcontainers/base:ubuntu

gitricko added 13 commits July 21, 2026 09:44
Ollama's install.sh requires zstd to extract its binary tarball.
Without it the build fails with:
  ERROR: This version requires zstd for extraction.
- Export OLLAMA_VERSION and OLLAMA_NO_START=1 as ENV in Dockerfile
  so the Ollama installer respects the pinned version and skips
  systemd service configuration during Docker build
- Add DEBIAN_FRONTEND=noninteractive to prevent interactive prompts
- Fix stray comma in self-check.sh associative array declaration
…ke tests

- Quote and sanitize log file path in start_service() to handle names with spaces (e.g. 'ollama serve')
- Use --entrypoint bash in CI docker run commands to avoid triggering the full entrypoint (which starts services, clones repos, etc.) during smoke/integration tests
- Wrap tailscale install.sh in subshell with || echo to prevent build failure
- Make tailscale check optional in smoke test (it's not critical for CI)
- Build job now always pushes to GHCR with ci-<run_id> temp tag
- Smoke Test, Integration Test, Image Size Report all pull pre-built image
- Added cleanup job to delete temp tag from GHCR after run completes
- GHCR login enabled for PR builds (was only push before)
- Estimated CI savings: ~9 minutes per run (13min → 4min)
…-check

- Remove --entrypoint bash so the real entrypoint.sh runs (starts ollama, modelrelay, omniroute, hermes gateway, hermes dashboard)
- Wait 30s for services to come up before running self-check
- Remove '|| echo non-blocking' so port failures now fail the CI job
- self-check.sh already exits code 2 on critical port failures (7352, 20128, 9119)
…erignore

- Combined all heavy installs (ollama, hermes, omniroute, tailscale, mnemon,
  cline, claude) into a single RUN layer to reduce layer count
- Added aggressive cleanup: apt-get clean, rm -rf /root/.npm /tmp/* /var/tmp/*
- Added .dockerignore to exclude .git, .github, node_modules, .hermes, etc.
- Reduced image layers from 15+ to ~3 (main install + COPYs + entrypoint)
- Should prevent BuildKit crash during 'preparing layers for inline cache'
… cleanup

The gh api user/packages endpoint requires a user PAT with read:packages
scope — GITHUB_TOKEN (installation token) gets 403. Switch to the OCI
Distribution API (ghcr.io/v2/...) which uses GHCR bearer tokens derived
from GITHUB_TOKEN's packages:write scope, enabling manifest deletion
by digest directly against the registry.

- Get bearer token from ghcr.io/token with delete scope
- Resolve tag to manifest digest via HEAD request
- DELETE the manifest by digest
- Graceful fallback if token or manifest unavailable
Fine-grained PATs (ghu_) and GITHUB_TOKEN both fail to delete GHCR
packages — the former returns 'UNSUPPORTED' on OCI DELETE, the latter
lacks the user/packages REST API scope. Classic PATs (ghp_) with
read:packages + write:packages are the only token type that supports
the GitHub REST API for package version deletion.

Changes:
- Use secrets.GHCR_CLEANUP_TOKEN (classic PAT) for auth
- Switch from OCI Distribution API to GitHub REST API
  (GET/DELETE /user/packages/container/{pkg}/versions/{id})
- Add pagination support for repos with many package versions
- Graceful skip with setup instructions if secret is not configured
The user/packages REST API scopes to the authenticated user, so
the package name should be 'hermes-codespace/devcontainer' not
'gitricko/hermes-codespace/devcontainer'. Without stripping the
username prefix, the API returns 404.
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.

2 participants