No description
| scripts | ||
| tf | ||
| .gitignore | ||
| app.env.example | ||
| Makefile | ||
| README.md | ||
Mycelium Deploy
Deploy any Docker Compose application to a ThreeFold Grid VM with a single command with Mycelium network IPv6 and ThreeFold IPv4 web gateway.
What you get
- Ubuntu 24.04 VM with public IPv4 + Mycelium connectivity
- Docker + Docker Compose pre-installed
- Cloudflare DNS A record (optional)
- Systemd service for auto-restart on reboot
- SSH access via public IP or Mycelium
Quick start
# 1. Configure credentials
cp tf/credentials.auto.tfvars.example tf/credentials.auto.tfvars
# Edit with your TFGrid mnemonic
# 2. Configure your app
cp app.env.example app.env
# Edit with your domain, git repo, etc.
# 3. Customize scripts/setup.sh for your app
# (Docker Compose commands, env vars, Caddyfile, etc.)
# 4. Deploy
make all
Makefile targets
| Target | Description |
|---|---|
make all |
Full deploy: init + deploy + setup + dns + test + info |
make init |
Initialize OpenTofu providers |
make deploy |
Provision VM on the grid |
make setup |
Install Docker + app on the VM |
make destroy |
Tear down all infrastructure |
make clean |
Remove generated and cached files |
make dns |
Set Cloudflare A record (auto-discovers zone ID) |
make test |
Verify services are responding |
make info |
Show endpoints and connection info |
make ssh |
SSH into the VM |
Structure
tfgrid_deploy/
├── Makefile # Orchestrator
├── app.env.example # App config template
├── .gitignore
├── tf/
│ ├── main.tf # VM + network + public IP + mycelium
│ ├── variables.tf # Input variables
│ ├── outputs.tf # IP addresses, SSH commands
│ └── credentials.auto.tfvars.example
└── scripts/
└── setup.sh # VM provisioning (customize this)
Customization
The main file to customize is scripts/setup.sh. It has numbered sections:
- Load config - reads app.env, derives domain
- Install packages - base Ubuntu packages
- Install Docker - with fuse-overlayfs (required on TFGrid)
- Clone app - git clone or pull your repo
- Generate .env - Docker Compose environment
- Caddyfile - reverse proxy config (commented out by default)
- Docker login - for private registries
- Start services - docker compose up
- Systemd service - auto-restart
- Health check - verify app is responding
For a typical app, you'll edit sections 4-6 and possibly 8.
Prerequisites
- OpenTofu (or Terraform) installed locally
- ThreeFold Grid account with funded wallet
- SSH key pair (
~/.ssh/id_ed25519.pubby default) curl,jqfor DNS and test targets
Pinning to a specific node
By default, the grid scheduler auto-selects a node. To pin:
# tf/credentials.auto.tfvars
node_id = 8
DNS
The make dns target manages Cloudflare A records. Set CLOUDFLARE_API_TOKEN in app.env. The zone ID is auto-discovered from your domain.
Examples
To deploy a WordPress site, you would:
- Set
GIT_REPOto your repo containingdocker-compose.ymlwith WordPress + MariaDB - Customize
setup.shsection 5 to generate the WordPress.env - Uncomment section 6 to generate a Caddyfile
make all