Skip to content

Bake MyBB into Docker image at build time instead of runtime#1

Draft
visualcookie wants to merge 3 commits intomainfrom
claude/mybb-backup-container-Aa7NN
Draft

Bake MyBB into Docker image at build time instead of runtime#1
visualcookie wants to merge 3 commits intomainfrom
claude/mybb-backup-container-Aa7NN

Conversation

@visualcookie
Copy link
Owner

Summary

This PR fundamentally changes how MyBB is delivered in the Docker image. Instead of downloading MyBB at container startup (runtime), MyBB is now pre-installed into the image at build time. This improves reliability, security, and deployment consistency.

Key Changes

  • Dockerfile: Added build-time MyBB installation that downloads and extracts MyBB during image build, storing it in /opt/mybb-source. Made MYBB_VERSION a required build argument.

  • GitHub Actions Workflow:

    • Made mybb_version input required for manual builds
    • Added LATEST_MYBB_VERSION environment variable for consistency
    • Reduced build-versions matrix to only build the 2 latest MyBB versions (1838, 1839) to reduce maintenance burden
    • Updated comments to clarify the new approach
  • Entrypoint Script:

    • Refactored to copy MyBB from pre-built image source instead of downloading
    • Added version tracking via .mybb_version files in both image and volume
    • Added version mismatch detection to warn users when image version differs from installed version
    • Kept download functionality for upgrade scenarios to versions not in the image
  • Docker Compose Files:

    • docker-compose.yml: Now uses MYBB_VERSION as a build argument (local development)
    • docker-compose.ghcr.yml: Uses MYBB_TAG to select pre-built image versions; removed runtime MYBB_VERSION env var
  • Documentation:

    • Updated README with new pre-built image approach
    • Added table of available image tags and versions
    • Clarified that MyBB version is determined by image tag, not environment variable
    • Updated upgrade instructions to use image tags instead of version downloads
    • Updated env.example with clearer configuration guidance

Implementation Details

  • MyBB is extracted to /opt/mybb-source during build and copied to /var/www/html at container startup
  • Version tracking uses .mybb_version files to detect mismatches between image and installed versions
  • Upgrade mode still supports downloading versions not in the image for flexibility
  • Pre-built images are only created for the 2 latest MyBB versions to reduce storage and maintenance overhead
  • All changes are backward compatible with existing deployments; users can still build locally with any version

Benefits

Reliability: No runtime downloads means faster startup and no network failures during container initialization
Security: MyBB source is verified at build time, not downloaded at runtime
Consistency: Every container from the same image has identical MyBB files
Simplicity: Clearer separation between build-time and runtime concerns
Maintainability: Reduced scope by focusing on 2 latest versions for pre-built images

https://claude.ai/code/session_017iViynCSN8iwn6NiUetwsp

Previously, MyBB was downloaded at container runtime which posed risks of
data loss if downloads failed during container recreation. Now:

- MyBB is downloaded and installed during Docker image build
- Each image contains a specific MyBB version (no runtime downloads)
- GitHub Actions builds images for the 2 latest MyBB versions (1838, 1839)
- Container startup copies pre-installed MyBB from image to volume
- Version mismatch detection warns when image differs from installed version
- Upgrade mode still works for migrating between versions

https://claude.ai/code/session_017iViynCSN8iwn6NiUetwsp
- Remove download_mybb/extract_mybb functions from entrypoint
- Upgrade mode now uses pre-installed MyBB from image instead of downloading
- Simplify docker-compose files and documentation
- Clean up verbose comments

https://claude.ai/code/session_017iViynCSN8iwn6NiUetwsp
Follow the approach used by mybb/docker - on every container start,
sync files from image to volume using rsync. Existing files are
preserved automatically (--ignore-existing), so configs, uploads,
plugins, and themes survive upgrades without special handling.

Changes:
- Rewrite entrypoint to ~100 lines (was ~450)
- Remove UPGRADE_MODE, PRESERVE_PLUGINS, PRESERVE_THEMES
- Add rsync to Dockerfile
- Simplify documentation

https://claude.ai/code/session_017iViynCSN8iwn6NiUetwsp
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