Skip to content

Fix slow docker issue#7

Merged
gitricko merged 3 commits into
gitricko:mainfrom
fredrickchew:fix-slow-docker-issue
Apr 20, 2026
Merged

Fix slow docker issue#7
gitricko merged 3 commits into
gitricko:mainfrom
fredrickchew:fix-slow-docker-issue

Conversation

@fredrickchew

Copy link
Copy Markdown
Contributor

Pull Request: Fix Slow Docker Startup Issue

Problem

The Docker container was experiencing slow startup times due to inefficient initialization scripts that used fixed sleep delays and improper file ownership handling.

Solution

Refactored the Dockerfile and startup scripts to:

  • Use proper file ownership with --chown flags during COPY operations
  • Replace fixed sleep delays with dynamic polling for configuration files
  • Improve script organization with numbered prefixes for execution order
  • Optimize model addition logic for better performance

Changes Made

Dockerfile Improvements

  • Replaced RUN echo commands with COPY operations for startup scripts
  • Added --chown=abc:abc flags to ensure proper file ownership
  • Renamed scripts with numbered prefixes for clear execution order:
    • start-picoclaw.shstart-1-picoclaw.sh
    • start-modelrelay.shstart-2-modelrelay.sh
    • Added start-3-ollama.sh

Startup Script Refactoring

  • start-2-modelrelay.sh:

    • Refactored model addition logic with more efficient jq queries
    • Added logic to set modelrelay as default for agents when no default exists
    • Replaced fixed 15-second sleep with dynamic polling (checks every 5 seconds for up to 5 minutes)
    • Improved error handling and ownership management
  • start-3-ollama.sh:

    • New dedicated script for Ollama background service startup
  • Removed: Old start-modelrelay.sh script

Benefits

  • Faster container startup by eliminating unnecessary delays
  • More reliable initialization with proper file ownership
  • Better script maintainability with clear naming conventions
  • Improved user experience with responsive configuration detection

Testing

  • Verified container builds successfully
  • Confirmed all services start in correct order
  • Validated modelrelay integration with PicoClaw configuration
  • Ensured proper file permissions and ownership

@gitricko gitricko merged commit 2e91f35 into gitricko:main Apr 20, 2026
2 checks passed
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