Pterodactyl Panel Module
This module deploys Pterodactyl Panel, a game server management panel, as Docker containers in the homelab environment.
Overview
The Pterodactyl Panel module:
- Deploys three Docker containers:
pterodactyl-panel: The main web UI and API serverpterodactyl-db: A MariaDB database backendpterodactyl-cache: A Redis cache server
- Creates a dedicated Docker network (
ptero-panel) for container communication - Persists data to volumes on the host
- Provides service definition for integration with networking modules
Usage
module "pterodactyl_panel" {
source = "./modules/20-services-apps/pterodactyl/panel"
volume_path = "/path/to/volumes/pterodactyl/panel"
networks = ["homelab-network"]
}
Variables
| Variable | Description | Type | Default |
|---|---|---|---|
image_tag |
Tag of the Pterodactyl Panel image to use | string |
"latest" |
volume_path |
Host path for Pterodactyl Panel volumes | string |
- |
networks |
List of networks to which the panel should be attached | list(string) |
[] |
Outputs
| Output | Description |
|---|---|
service_definition |
Service definition for integration with networking modules |
Service Definition
This module outputs a service definition that is used by the networking modules to expose the service.
{
name = "pterodactyl-panel"
primary_port = 80
endpoint = "http://pterodactyl-panel:80"
subdomains = ["gameservers"]
publish_via = "tunnel"
}
Environment Variables
Pterodactyl Panel requires several environment variables to function properly. These are stored in a .env file in the module directory and read using the dotenv Terraform provider. Key variables include:
-
Panel Configuration:
APP_URL: The URL where the panel will be accessedAPP_TIMEZONE: The timezone for the applicationAPP_SERVICE_AUTHOR: Service author information
-
Database Configuration:
MYSQL_PASSWORD: Database passwordMYSQL_ROOT_PASSWORD: Database root passwordMYSQL_DATABASE: Database nameMYSQL_USER: Database username
-
Mail Configuration:
- Mail settings are automatically sourced from the global SMTP module
Data Persistence
Pterodactyl Panel stores its data in multiple volumes:
- Application data:
/app/varin the container, mapped to${volume_path}/varon the host - Nginx configuration:
/etc/nginx/http.din the container, mapped to${volume_path}/nginxon the host - SSL certificates:
/etc/letsencryptin the container, mapped to${volume_path}/certson the host - Logs:
/app/storage/logsin the container, mapped to${volume_path}/logson the host - Database data:
/var/lib/mysqlin the MariaDB container, mapped to${volume_path}/databaseon the host
Networking
The module creates a dedicated Docker network named ptero-panel for communication between the panel, database, and cache containers. The panel container is also attached to any additional networks specified in the networks variable, allowing it to communicate with other services in the homelab.
Integration with Networking Modules
This service is configured to be exposed through a Cloudflare tunnel for secure remote access, set by publish_via = "tunnel".
Example Integration in Main Configuration
module "pterodactyl_panel" {
source = "./modules/20-services-apps/pterodactyl/panel"
volume_path = module.system_globals.volume_host
networks = [module.services.homelab_docker_network_name]
}
# The service definition is automatically included in the services output
module "services" {
source = "./modules/services"
# ...
service_definitions = [
module.pterodactyl_panel.service_definition,
# Other service definitions
]
}