wordpress

command
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2025 License: MIT Imports: 22 Imported by: 0

README ΒΆ

πŸš€ WordPress Multi-Service Scale Example

This example shows how to use go-contain to programmatically build, deploy, and manage a scaled WordPress environment β€” all with native Go code.


πŸ› οΈ What It Does

  • πŸ“¦ Creates a Docker Compose project with:

    • 1 MySQL database container
    • Multiple individual WordPress containers (scaled separately by NumWordPress)
    • An HAProxy container for load balancing
    • Optional Portainer container (skipped on Windows)
  • βš™οΈ Dynamically generates HAProxy config for round-robin load balancing

  • πŸ“ Exports a docker-compose.yaml compatible with Docker Compose CLI

  • ▢️ Runs docker compose up in detached mode with:

    • Orphan container cleanup
    • Custom colored log output
  • πŸ“‘ Streams container logs and supports graceful shutdown on Ctrl+C

  • 🧹 Runs docker compose down on exit, cleaning containers, images, volumes, and orphans


πŸ’‘ Key Highlights

  • πŸ“Œ Declarative & reusable container/service definitions in Go functions
  • πŸ”„ Dynamic scaling with distinct WordPress services chained by dependencies
  • 🩺 Built-in health checks for critical services like MySQL and WordPress
  • 🧩 Conditional logic for cross-platform compatibility
  • ⚑ Graceful lifecycle management with Go contexts and OS signal handling
  • 🎨 Custom logger adds colored action prefixes ([up], [logs], [down]) for clarity

▢️ How to Run

In project root directory.

go run ./examples/wordpress/main.go
  • Exports docker-compose.yaml to ./examples/wordpress/
  • Starts all containers and streams logs live (with custom logger)
  • Press Ctrl+C to stop and clean up all resources automatically

πŸ“ Note

The wordpress.Up function does not require exporting the Compose project to a YAML file beforehand. You can run and manage your multi-container application entirely in-memory and programmatically, giving you full dynamic control without ever writing YAML to disk.

Exporting YAML is optional and primarily for compatibility, sharing, or debugging purposes.


This example proves that go-contain isn’t just for simple apps β€” it can handle complex, scaled multi-service setups with full programmatic control, dynamic config generation, and smooth lifecycle orchestration β€” all in idiomatic Go! πŸŽ‰


Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL