### Install Provider Locally Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/README.md Install the provider binary to the local Go bin directory. ```shell go install ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/sandbox/README.md Prepare the environment by copying the example variables file to the required configuration file. ```shell cd sandbox cp example.terraform.tfvars terraform.tfvars ``` -------------------------------- ### Define Dokploy Resources Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/README.md Example showing the creation of a project, environment, application, and domain configuration. ```hcl # Create a project resource "dokploy_project" "main" { name = "my-project" description = "My application infrastructure" } # Create an environment resource "dokploy_environment" "production" { name = "production" project_id = dokploy_project.main.id } # Deploy an application resource "dokploy_application" "web" { name = "web-app" project_id = dokploy_project.main.id environment_id = dokploy_environment.production.id custom_git_url = "https://github.com/username/repo.git" custom_git_branch = "main" build_type = "dockerfile" auto_deploy = true } # Configure a domain resource "dokploy_domain" "web_domain" { application_id = dokploy_application.web.id generate_traefik_me = true port = 3000 https = true } ``` -------------------------------- ### Configure Dokploy Mounts Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/mount.md Examples demonstrating volume, bind, and file mount configurations for applications and databases. ```terraform # Volume mount example resource "dokploy_mount" "app_data" { service_id = dokploy_application.myapp.id service_type = "application" type = "volume" volume_name = "app-data" mount_path = "/app/data" } # Bind mount example resource "dokploy_mount" "config" { service_id = dokploy_application.myapp.id service_type = "application" type = "bind" host_path = "/host/config" mount_path = "/app/config" } # File mount example resource "dokploy_mount" "env_file" { service_id = dokploy_application.myapp.id service_type = "application" type = "file" file_path = "/app/.env" mount_path = "/app/.env" content = <<-EOT DATABASE_URL=postgresql://user:pass@db:5432/mydb REDIS_URL=redis://redis:6379 EOT } # Database volume mount example resource "dokploy_mount" "postgres_data" { service_id = dokploy_database.postgres.id service_type = "postgres" type = "volume" volume_name = "postgres-data" mount_path = "/var/lib/postgresql/data" } ``` -------------------------------- ### Configure Dokploy Port Mappings Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/port.md Examples showing how to expose various services like PostgreSQL, Redis, DNS, and gRPC using the dokploy_port resource. ```terraform # Expose PostgreSQL port resource "dokploy_port" "postgres" { application_id = dokploy_application.postgres.id published_port = 5432 target_port = 5432 protocol = "tcp" publish_mode = "host" } # Expose Redis port resource "dokploy_port" "redis" { application_id = dokploy_application.redis.id published_port = 6379 target_port = 6379 protocol = "tcp" publish_mode = "ingress" } # Expose custom UDP service resource "dokploy_port" "dns" { application_id = dokploy_application.dns_server.id published_port = 53 target_port = 53 protocol = "udp" publish_mode = "host" } # Expose gRPC service resource "dokploy_port" "grpc" { application_id = dokploy_application.api.id published_port = 50051 target_port = 50051 protocol = "tcp" publish_mode = "ingress" } ``` -------------------------------- ### Deploy from GitHub Repository Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/compose.md Configures a compose stack deployment using a GitHub App installation ID. ```terraform resource "dokploy_compose" "github_stack" { name = "my-stack" environment_id = dokploy_environment.production.id source_type = "github" # GitHub settings github_id = "your-github-app-installation-id" owner = "myorg" repository = "docker-stack" branch = "main" compose_path = "./docker-compose.yml" auto_deploy = true deploy_on_create = true } ``` -------------------------------- ### dokploy_ai_models Data Source Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/data-sources/ai_models.md Fetches available models from an AI provider to assist in AI configuration setup. ```APIDOC ## Data Source: dokploy_ai_models ### Description Fetches available models from an AI provider. Useful for discovering which models are available before creating an AI configuration. ### Required Parameters - **api_key** (String, Sensitive) - Required - API key for authenticating with the AI provider. - **api_url** (String) - Required - The API endpoint URL for the AI provider (e.g., https://api.openai.com/v1). ### Read-Only Attributes - **models** (Attributes List) - List of available models from the AI provider. #### Nested Schema for models - **created** (Number) - Unix timestamp when the model was created. - **id** (String) - The model identifier (e.g., gpt-4, gpt-4o). - **object** (String) - The object type (usually 'model'). - **owned_by** (String) - The organization that owns the model. ``` -------------------------------- ### Build the Provider Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/README.md Compile the provider binary using Go. ```shell go build . ``` -------------------------------- ### Generate Documentation Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/README.md Use the makefile to generate provider documentation. ```shell make generate ``` -------------------------------- ### Prepare Environment Variables for Testing Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/README.md Create a .env file to configure test parameters. ```shell cp .env.example .env # Edit .env and set: # - DOKPLOY_HOST=https://your-instance.com/api # - DOKPLOY_API_KEY=your-api-key # - TF_ACC=1 ``` -------------------------------- ### Configure Docker Registries in Terraform Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/registry.md Examples of defining various container registry types including cloud providers and self-hosted instances. ```terraform # GitHub Container Registry (ghcr.io) resource "dokploy_registry" "ghcr" { registry_name = "GitHub Container Registry" registry_type = "cloud" registry_url = "ghcr.io" username = "myorg" password = var.github_token image_prefix = "ghcr.io/myorg" } # Docker Hub resource "dokploy_registry" "dockerhub" { registry_name = "Docker Hub" registry_type = "cloud" registry_url = "docker.io" username = "myusername" password = var.dockerhub_token image_prefix = "docker.io/myusername" } # AWS ECR resource "dokploy_registry" "ecr" { registry_name = "AWS ECR" registry_type = "cloud" registry_url = "123456789012.dkr.ecr.us-east-1.amazonaws.com" username = "AWS" password = var.ecr_token image_prefix = "123456789012.dkr.ecr.us-east-1.amazonaws.com/myapp" } # Google Container Registry (GCR) resource "dokploy_registry" "gcr" { registry_name = "Google Container Registry" registry_type = "cloud" registry_url = "gcr.io" username = "_json_key" password = var.gcp_service_account_key image_prefix = "gcr.io/my-project" } # Registry with specific server resource "dokploy_registry" "build_server_registry" { registry_name = "Build Server Registry" registry_type = "cloud" registry_url = "registry.example.com" username = "admin" password = var.registry_password image_prefix = "registry.example.com/myapp" server_id = dokploy_server.build.id } # Self-hosted Harbor registry resource "dokploy_registry" "harbor" { registry_name = "Harbor Registry" registry_type = "cloud" registry_url = "harbor.example.com" username = "robot$myrobot" password = var.harbor_robot_token image_prefix = "harbor.example.com/library" } ``` -------------------------------- ### Build Provider Binary Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/sandbox/README.md Compile the provider binary from the project root directory. ```shell go build -o terraform-provider-dokploy . ``` -------------------------------- ### Initialize and Apply Terraform Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/sandbox/README.md Configure the CLI to use the local provider and execute Terraform commands within the sandbox directory. ```shell # (Inside sandbox directory) # Export CLI config for local provider overrides export TF_CLI_CONFIG_FILE=$(pwd)/dev.tfrc # Initialize other providers (tls, github) terraform init # Apply changes terraform apply ``` -------------------------------- ### Configure the dokploy provider Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/index.md Initialize the provider by specifying the host URL and API key. ```terraform provider "dokploy" { host = "https://your-dokploy.com/api" api_key = "your-api-key" } ``` -------------------------------- ### Create a Dokploy Project Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/project.md Defines a new project resource with a name and description. ```terraform resource "dokploy_project" "example" { name = "My Project" description = "A project managed by Terraform" } ``` -------------------------------- ### Create a basic Redis instance Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/redis.md Defines a standard Redis instance within a project and environment. ```terraform resource "dokploy_project" "main" { name = "my-project" description = "Main project" } resource "dokploy_environment" "production" { project_id = dokploy_project.main.id name = "production" } resource "dokploy_redis" "cache" { name = "app-cache" app_name_prefix = "redis-cache" database_password = var.redis_password environment_id = dokploy_environment.production.id } ``` -------------------------------- ### Deploy Docker Image Application Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/application.md Deploys a pre-built Docker image from a registry. Requires a project and environment to be defined first. ```terraform resource "dokploy_project" "myproject" { name = "My Application" } resource "dokploy_environment" "production" { project_id = dokploy_project.myproject.id name = "Production" description = "Production environment" } resource "dokploy_application" "nginx" { name = "nginx-app" environment_id = dokploy_environment.production.id source_type = "docker" docker_image = "nginx:alpine" replicas = 2 deploy_on_create = true } ``` -------------------------------- ### Deploy Static Site Application Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/application.md Configures a static site deployment from a GitHub repository with SPA routing enabled. ```terraform resource "dokploy_application" "docs" { name = "documentation" environment_id = dokploy_environment.production.id source_type = "github" github_id = "your-github-app-installation-id" github_owner = "myorg" github_repository = "docs" github_branch = "main" # Static build build_type = "static" publish_directory = "build" is_static_spa = true # Enable SPA routing auto_deploy = true deploy_on_create = true } ``` -------------------------------- ### Clone the Repository Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/README.md Commands to clone the provider source code. ```shell git clone https://github.com/ahmedali6/terraform-provider-dokploy.git cd terraform-provider-dokploy ``` -------------------------------- ### Configure a basic deployment server Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/server.md Defines a server for deployment tasks, requiring a pre-configured SSH key resource. ```terraform resource "dokploy_ssh_key" "deploy" { name = "deploy-key" public_key = file("~/.ssh/id_rsa.pub") private_key = file("~/.ssh/id_rsa") } resource "dokploy_server" "worker" { name = "worker-1" description = "Worker server for deployments" ip_address = "192.168.1.100" port = 22 username = "root" ssh_key_id = dokploy_ssh_key.deploy.id server_type = "deploy" } ``` -------------------------------- ### Create a dokploy_ssh_key resource Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/ssh_key.md Defines an SSH key resource with a name, description, and file paths for public and private keys. ```terraform resource "dokploy_ssh_key" "deploy" { name = "deploy-key" description = "Deployment SSH key" public_key = file("~/.ssh/id_rsa.pub") private_key = file("~/.ssh/id_rsa") } ``` -------------------------------- ### Run Provider Tests Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/README.md Execute the test suite for the provider. ```shell go test -v ./... ``` -------------------------------- ### Enable Preview Deployments Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/application.md Configures automatic preview deployments for pull requests with custom environment variables. ```terraform resource "dokploy_application" "with_previews" { name = "app-with-previews" environment_id = dokploy_environment.production.id source_type = "github" github_id = "your-github-app-installation-id" github_owner = "myorg" github_repository = "web" github_branch = "main" build_type = "nixpacks" # Preview deployment settings preview_deployments_enabled = true preview_wildcard = "*.preview.example.com" preview_port = 3000 preview_https = true preview_certificate_type = "letsencrypt" preview_limit = 5 preview_env = <<-EOT NODE_ENV=preview API_URL=https://api-preview.example.com EOT auto_deploy = true deploy_on_create = true } ``` -------------------------------- ### Import a server resource Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/server.md Use the terraform import command to bring an existing server into state management using its unique ID. ```shell # Servers can be imported using their ID terraform import dokploy_server.worker "server-id-123" ``` -------------------------------- ### Deploy Gitea Repository Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/application.md Deploys an application from a Gitea repository. ```terraform resource "dokploy_application" "gitea_app" { name = "gitea-app" environment_id = dokploy_environment.production.id source_type = "gitea" # Gitea settings gitea_id = "your-gitea-integration-id" gitea_owner = "myorg" gitea_repository = "myrepo" gitea_branch = "main" build_type = "nixpacks" auto_deploy = true deploy_on_create = true } ``` -------------------------------- ### dokploy_application Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/application.md The dokploy_application resource is the primary interface for deploying applications. It supports multiple source types (git, github, docker) and various build configurations. ```APIDOC ## Terraform Resource: dokploy_application ### Description Defines an application deployment in Dokploy. This resource manages the lifecycle of an application, including source configuration, build settings, and deployment parameters. ### Configuration Parameters - **name** (string) - Required - The name of the application. - **environment_id** (string) - Required - The ID of the environment where the application is deployed. - **source_type** (string) - Required - The source of the application code (e.g., "git", "github", "docker"). - **build_type** (string) - Optional - The build strategy (e.g., "dockerfile", "static", "nixpacks"). - **auto_deploy** (boolean) - Optional - Whether to enable automatic deployments. - **deploy_on_create** (boolean) - Optional - Whether to trigger a deployment immediately upon resource creation. ### Example Usage ```terraform resource "dokploy_application" "example" { name = "my-app" environment_id = "env-123" source_type = "github" github_owner = "myorg" github_repository = "my-repo" build_type = "dockerfile" deploy_on_create = true } ``` ``` -------------------------------- ### Deploy Bitbucket Repository Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/application.md Deploys an application from a Bitbucket repository. ```terraform resource "dokploy_application" "bitbucket_app" { name = "bitbucket-app" environment_id = dokploy_environment.production.id source_type = "bitbucket" # Bitbucket settings bitbucket_id = "your-bitbucket-integration-id" bitbucket_owner = "myworkspace" bitbucket_repository = "myrepo" bitbucket_branch = "main" build_type = "nixpacks" auto_deploy = true deploy_on_create = true } ``` -------------------------------- ### dokploy Provider Configuration Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/index.md The dokploy provider requires a host URL and an API key to authenticate and interact with the Dokploy instance. ```APIDOC ## Provider Configuration ### Description Configures the dokploy provider to communicate with a specific Dokploy instance. ### Schema - **host** (String) - Required - The URL of your Dokploy instance (e.g., https://dokploy.example.com/api) - **api_key** (String, Sensitive) - Required - Your Dokploy API Key ### Example Usage ```terraform provider "dokploy" { host = "https://your-dokploy.com/api" api_key = "your-api-key" } ``` ``` -------------------------------- ### Deploy GitHub Repository with Nixpacks Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/application.md Deploys from a GitHub repository using Nixpacks for automatic build detection. ```terraform resource "dokploy_application" "api" { name = "api" environment_id = dokploy_environment.production.id source_type = "github" # GitHub settings (using github_* prefix for consistency with other providers) github_id = "your-github-app-installation-id" github_owner = "myorg" github_repository = "api" github_branch = "main" # Build settings (Nixpacks auto-detects your project type) build_type = "nixpacks" # Runtime settings auto_deploy = true deploy_on_create = true # Environment variables env = <<-EOT NODE_ENV=production DATABASE_URL=${var.database_url} EOT } ``` -------------------------------- ### Create a Dokploy Environment Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/environment.md Defines a new environment linked to a specific project using the project's ID. ```terraform resource "dokploy_project" "myproject" { name = "My Application" } resource "dokploy_environment" "production" { name = "Production" description = "Production environment" project_id = dokploy_project.myproject.id } ``` -------------------------------- ### Import Dokploy Mount Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/mount.md Syntax for importing an existing mount into Terraform state using its unique ID. ```shell # Mounts can be imported using their ID terraform import dokploy_mount.app_data "mount-id-123" ``` -------------------------------- ### Deploy GitLab Repository Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/application.md Deploys an application from a GitLab repository. ```terraform resource "dokploy_application" "gitlab_app" { name = "gitlab-app" environment_id = dokploy_environment.production.id source_type = "gitlab" # GitLab settings gitlab_id = "your-gitlab-integration-id" gitlab_project_id = 12345 gitlab_owner = "mygroup" gitlab_repository = "myproject" gitlab_branch = "main" build_type = "nixpacks" auto_deploy = true deploy_on_create = true } ``` -------------------------------- ### dokploy_application Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/application.md The dokploy_application resource manages the lifecycle and configuration of applications within Dokploy. It supports multiple deployment strategies including Docker Swarm orchestration, monorepo path-based triggers, and direct Dockerfile uploads. ```APIDOC ## Terraform Resource: dokploy_application ### Description Manages an application deployment within Dokploy. This resource supports various source types and advanced configuration options like Docker Swarm settings, path-based deployment triggers, and raw Dockerfile deployments. ### Configuration Examples #### Docker Swarm Configuration ```hcl resource "dokploy_application" "swarm_app" { name = "swarm-configured-app" environment_id = dokploy_environment.production.id source_type = "docker" docker_image = "nginx:alpine" replicas = 3 health_check_swarm = jsonencode({ ... }) restart_policy_swarm = jsonencode({ ... }) update_config_swarm = jsonencode({ ... }) placement_swarm = jsonencode({ ... }) stop_grace_period_swarm = 30000000000 deploy_on_create = true } ``` #### Monorepo Watch Paths ```hcl resource "dokploy_application" "monorepo_app" { name = "monorepo-service" environment_id = dokploy_environment.production.id source_type = "github" github_id = "..." github_owner = "..." github_repository = "..." github_branch = "main" github_build_path = "services/api" watch_paths = ["services/api/**", "shared/lib/**", "package.json"] build_type = "nixpacks" auto_deploy = true deploy_on_create = true } ``` #### Drop Source (Dockerfile Upload) ```hcl resource "dokploy_application" "drop_app" { name = "quick-deploy" environment_id = dokploy_environment.production.id source_type = "drop" dockerfile = "FROM nginx:alpine..." drop_build_path = "/app" deploy_on_create = true } ``` ``` -------------------------------- ### dokploy_application Data Source Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/data-sources/application.md Retrieves configuration and status details for a specific Dokploy application. ```APIDOC ## dokploy_application (Data Source) ### Description Fetches a single Dokploy application by its ID. ### Required Parameters - **id** (String) - The unique identifier of the application. ### Read-Only Attributes - **app_name** (String) - The app name used for Docker container naming. - **application_status** (String) - Current status: idle, running, done, or error. - **auto_deploy** (Boolean) - Whether auto-deploy is enabled. - **branch** (String) - GitHub branch name. - **build_type** (String) - The build type: dockerfile, heroku_buildpacks, paketo_buildpacks, nixpacks, static, or railpack. - **created_at** (String) - Timestamp when the application was created. - **custom_git_branch** (String) - Branch for custom Git repository. - **custom_git_url** (String) - Custom Git repository URL. - **description** (String) - Description of the application. - **docker_image** (String) - Docker image name (for docker source type). - **environment_id** (String) - The environment ID this application belongs to. - **name** (String) - The display name of the application. - **owner** (String) - GitHub repository owner. - **registry_url** (String) - Docker registry URL. - **replicas** (Number) - Number of replicas. - **repository** (String) - GitHub repository name. - **server_id** (String) - Server ID the application is deployed to. - **source_type** (String) - The source type: github, gitlab, bitbucket, gitea, git, docker, or drop. - **traefik_config** (String) - Custom Traefik configuration for the application. ``` -------------------------------- ### Import a Dokploy Project Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/project.md Uses the terraform import command to bring an existing project into state management using its ID. ```shell # Projects can be imported using their ID terraform import dokploy_project.example "project-id-123" ``` -------------------------------- ### Deploy from Bitbucket Repository Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/compose.md Configures a compose stack deployment using a Bitbucket integration ID. ```terraform resource "dokploy_compose" "bitbucket_stack" { name = "bitbucket-stack" environment_id = dokploy_environment.production.id source_type = "bitbucket" # Bitbucket settings bitbucket_id = "your-bitbucket-integration-id" bitbucket_owner = "myworkspace" bitbucket_repository = "docker-stack" bitbucket_branch = "main" compose_path = "./docker-compose.yml" auto_deploy = true deploy_on_create = true } ``` -------------------------------- ### Deploy GitHub Repository with Dockerfile Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/application.md Deploys from a GitHub repository using a specific Dockerfile and build context. ```terraform resource "dokploy_application" "web" { name = "web" environment_id = dokploy_environment.production.id source_type = "github" github_id = "your-github-app-installation-id" github_owner = "myorg" github_repository = "web-frontend" github_branch = "main" github_build_path = "apps/web" # Monorepo path # Dockerfile build build_type = "dockerfile" dockerfile_path = "./Dockerfile" docker_context_path = "." docker_build_stage = "production" # Multi-stage build target # Build arguments build_args = <<-EOT NODE_VERSION=20 BUILD_DATE=${timestamp()} EOT auto_deploy = true deploy_on_create = true } ``` -------------------------------- ### Import a Registry Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/registry.md Use the terraform import command to bring an existing registry into state management. ```shell # Registries can be imported using their ID terraform import dokploy_registry.ghcr "registry-id-123" ``` -------------------------------- ### Deploy from GitLab Repository Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/compose.md Configures a compose stack deployment using a GitLab integration ID and project details. ```terraform resource "dokploy_compose" "gitlab_stack" { name = "gitlab-stack" environment_id = dokploy_environment.production.id source_type = "gitlab" # GitLab settings gitlab_id = "your-gitlab-integration-id" gitlab_project_id = 12345 gitlab_owner = "mygroup" gitlab_repository = "docker-stack" gitlab_branch = "main" compose_path = "./docker-compose.yml" auto_deploy = true deploy_on_create = true } ``` -------------------------------- ### dokploy_mysql Resource Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/mysql.md The dokploy_mysql resource manages the lifecycle of a MySQL database instance. It requires specific database credentials and environment identifiers to provision the instance. ```APIDOC ## dokploy_mysql (Resource) ### Description Manages a MySQL database instance in Dokploy. ### Required Parameters - **app_name** (String) - Application name prefix for the MySQL instance. Dokploy will append a random suffix. - **database_name** (String) - Name of the database to create. - **database_password** (String, Sensitive) - Password for the database user. - **database_root_password** (String, Sensitive) - Root password for the MySQL instance. - **database_user** (String) - Database user name. - **environment_id** (String) - ID of the environment to deploy the MySQL instance in. - **name** (String) - Name of the MySQL instance. ### Optional Parameters - **command** (String) - Custom command to run in the container. - **cpu_limit** (String) - CPU limit for the container. - **cpu_reservation** (String) - CPU reservation for the container. - **description** (String) - Description of the MySQL instance. - **docker_image** (String) - Docker image to use (defaults to mysql:8). - **env** (String) - Environment variables for the container. - **external_port** (Number) - External port to expose the MySQL instance. - **memory_limit** (String) - Memory limit for the container. - **memory_reservation** (String) - Memory reservation for the container. - **replicas** (Number) - Number of replicas for the MySQL instance. - **server_id** (String) - ID of the server to deploy the MySQL instance on. ### Read-Only Attributes - **application_status** (String) - Current status of the MySQL application (idle, running, done, error). - **id** (String) - Unique identifier for the MySQL instance. ``` -------------------------------- ### Import an existing dokploy_domain resource Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/domain.md Uses the Terraform import command to bring an existing domain resource into state management. ```shell terraform import dokploy_domain.myapp "domain-id-123" ``` -------------------------------- ### Deploy from Gitea Repository Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/compose.md Configures a compose stack deployment using a Gitea integration ID. ```terraform resource "dokploy_compose" "gitea_stack" { name = "gitea-stack" environment_id = dokploy_environment.production.id source_type = "gitea" # Gitea settings gitea_id = "your-gitea-integration-id" gitea_owner = "myorg" gitea_repository = "docker-stack" gitea_branch = "main" compose_path = "./docker-compose.yml" auto_deploy = true deploy_on_create = true } ``` -------------------------------- ### dokploy_ai Resource Schema Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/ai.md Defines the configuration parameters for the dokploy_ai resource, including required authentication fields and optional settings. ```APIDOC ## Resource: dokploy_ai ### Description Manages an AI provider configuration in Dokploy, enabling integration with services like OpenAI for suggestions and deployments. ### Required Parameters - **api_key** (String, Sensitive) - API key for authenticating with the AI provider. - **api_url** (String) - The API endpoint URL for the AI provider (e.g., https://api.openai.com/v1). - **model** (String) - The model to use (e.g., gpt-4, gpt-4o, gpt-3.5-turbo). - **name** (String) - Display name for the AI provider configuration. ### Optional Parameters - **is_enabled** (Boolean) - Whether the AI configuration is enabled. Defaults to true. ### Read-Only Attributes - **created_at** (String) - Timestamp when the AI configuration was created. - **id** (String) - Unique identifier for the AI configuration. - **organization_id** (String) - The organization ID this AI configuration belongs to. ``` -------------------------------- ### Import Dokploy Application Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/application.md Use this command to import an existing application into your Terraform state file by specifying the resource type and the application ID. ```shell terraform import dokploy_application.myapp "application-id-123" ``` -------------------------------- ### Deploy Application from Custom Git Repository Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/application.md Uses an SSH key for authentication to deploy from a private Git repository. ```terraform resource "dokploy_ssh_key" "deploy_key" { name = "deploy-key" private_key = var.ssh_private_key public_key = var.ssh_public_key } resource "dokploy_application" "custom_git" { name = "custom-app" environment_id = dokploy_environment.production.id source_type = "git" # Custom Git settings custom_git_url = "git@github.com:myorg/private-repo.git" custom_git_branch = "main" custom_git_ssh_key_id = dokploy_ssh_key.deploy_key.id custom_git_build_path = "." enable_submodules = true build_type = "dockerfile" dockerfile_path = "./Dockerfile" auto_deploy = true deploy_on_create = true } ``` -------------------------------- ### Configure a build server Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/server.md Defines a dedicated build server for processing workloads. ```terraform resource "dokploy_server" "builder" { name = "build-server" description = "Dedicated build server" ip_address = "192.168.1.101" port = 22 username = "root" ssh_key_id = dokploy_ssh_key.deploy.id server_type = "build" } ``` -------------------------------- ### Import a Dokploy Environment Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/environment.md Imports an existing environment into the Terraform state using its unique ID. ```shell terraform import dokploy_environment.production "environment-id-123" ``` -------------------------------- ### Destroy Resources Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/sandbox/README.md Clean up created resources by running the destroy command with the local configuration file. ```shell export TF_CLI_CONFIG_FILE=$(pwd)/dev.tfrc terraform destroy ``` -------------------------------- ### Deploy application using raw Dockerfile content Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/application.md Deploys an application by providing raw Dockerfile content directly in the configuration using the drop source type. ```terraform resource "dokploy_application" "drop_app" { name = "quick-deploy" environment_id = dokploy_environment.production.id source_type = "drop" # Raw Dockerfile content dockerfile = <<-DOCKERFILE FROM nginx:alpine COPY . /usr/share/nginx/html EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] DOCKERFILE drop_build_path = "/app" deploy_on_create = true } ``` -------------------------------- ### Configure Remote Build Server Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/application.md Offloads build processes to a dedicated server and pushes the resulting image to a registry. ```terraform resource "dokploy_application" "remote_build" { name = "remote-build-app" environment_id = dokploy_environment.production.id source_type = "github" github_id = "your-github-app-installation-id" github_owner = "myorg" github_repository = "heavy-build" github_branch = "main" build_type = "dockerfile" # Remote build configuration build_server_id = dokploy_server.build.id build_registry_id = dokploy_registry.internal.id deploy_on_create = true } ``` -------------------------------- ### Configure Terraform Dev Overrides Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/README.md Set up the .terraformrc file to use a local build of the provider. ```shell # Create or edit ~/.terraformrc cat > ~/.terraformrc << EOF provider_installation { dev_overrides { "ahmedali6/dokploy" = "/path/to/your/go/bin" } direct {} } EOF ``` -------------------------------- ### dokploy_applications Data Source Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/data-sources/applications.md Retrieves a list of Dokploy applications. Can be filtered by environment_id. ```APIDOC ## Data Source: dokploy_applications ### Description Fetches all Dokploy applications, optionally filtered by environment. ### Parameters #### Optional - **environment_id** (String) - Optional - Environment ID to filter applications. If not provided, returns all applications across all environments. ### Read-Only Attributes - **applications** (Attributes List) - List of applications. ### Nested Schema for applications - **app_name** (String) - The app name used for Docker container naming. - **application_status** (String) - Current status: idle, running, done, or error. - **auto_deploy** (Boolean) - Whether auto-deploy is enabled. - **build_type** (String) - The build type: dockerfile, heroku_buildpacks, paketo_buildpacks, nixpacks, static, or railpack. - **created_at** (String) - Timestamp when the application was created. - **description** (String) - Description of the application. - **environment_id** (String) - The environment ID this application belongs to. - **id** (String) - The unique identifier of the application. - **name** (String) - The display name of the application. - **replicas** (Number) - Number of replicas. - **server_id** (String) - Server ID the application is deployed to. - **source_type** (String) - The source type: github, gitlab, bitbucket, gitea, git, docker, or drop. ``` -------------------------------- ### Import an existing Redis instance Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/redis.md Uses the Terraform import command to bring an existing Redis instance under management. ```shell # Redis instances can be imported using their ID terraform import dokploy_redis.cache "redis-id-123" ``` -------------------------------- ### Import a dokploy_ssh_key resource Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/ssh_key.md Uses the terraform import command to bring an existing SSH key into state management. ```shell terraform import dokploy_ssh_key.deploy "ssh-key-id-123" ``` -------------------------------- ### Configure Application Resource Limits Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/application.md Sets memory and CPU constraints for a Docker-based application deployment. ```terraform resource "dokploy_application" "resource_limited" { name = "limited-app" environment_id = dokploy_environment.production.id source_type = "docker" docker_image = "myapp:latest" # Resource limits memory_limit = 536870912 # 512MB memory_reservation = 268435456 # 256MB cpu_limit = 1000000000 # 1 CPU core cpu_reservation = 500000000 # 0.5 CPU core replicas = 3 deploy_on_create = true } ``` -------------------------------- ### dokploy_project Resource Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/project.md The dokploy_project resource allows you to define and manage projects in Dokploy. ```APIDOC ## Resource: dokploy_project ### Description Manages a project within Dokploy. ### Schema #### Required - **name** (String) - The name of the project. #### Optional - **description** (String) - A description of the project. #### Read-Only - **id** (String) - The unique identifier for the project. ### Import Projects can be imported using the terraform import command with the project ID: `terraform import dokploy_project.example "project-id-123"` ``` -------------------------------- ### dokploy_volume_backup (Resource) Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/volume_backup.md Resource definition for managing volume backups in Dokploy. ```APIDOC ## dokploy_volume_backup (Resource) ### Description Manages volume backups in Dokploy for backing up Docker volumes from applications, databases, and compose services. ### Required Parameters - **app_name** (String) - Docker app/service name. - **cron_expression** (String) - Cron schedule for backups. - **destination_id** (String) - ID of the backup destination. - **name** (String) - Name of the volume backup configuration. - **prefix** (String) - Prefix for backup files in the destination storage. - **service_id** (String) - ID of the service to backup. - **service_type** (String) - Type of service to backup (application, postgres, mysql, mariadb, mongo, redis, or compose). - **volume_name** (String) - Name of the Docker volume to backup. ### Optional Parameters - **enabled** (Boolean) - Whether the backup schedule is enabled. Default: true. - **keep_latest_count** (Number) - Number of recent backups to keep. Default: 5. - **service_name** (String) - Service name within a compose stack. Required when service_type is 'compose'. - **turn_off** (Boolean) - Whether to stop the service during backup for data consistency. Default: false. ### Read-Only Attributes - **created_at** (String) - Timestamp when the volume backup was created. - **id** (String) - Unique identifier for the volume backup. ``` -------------------------------- ### dokploy_gitlab_providers Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/data-sources/gitlab_providers.md Fetches the list of GitLab providers configured in Dokploy. ```APIDOC ## dokploy_gitlab_providers (Data Source) ### Description Fetches the list of GitLab providers configured in Dokploy. ### Schema #### Read-Only - **providers** (Attributes List) - List of GitLab providers. ### Nested Schema for `providers` - **created_at** (String) - The creation timestamp of the provider. - **git_provider_id** (String) - The git provider ID. - **gitlab_url** (String) - The GitLab instance URL. - **id** (String) - The unique identifier (gitlabId) of the GitLab provider. - **name** (String) - The name of the GitLab provider. - **organization_id** (String) - The Dokploy organization ID this provider belongs to. - **provider_type** (String) - The type of provider (gitlab). ``` -------------------------------- ### Configure Basic Database Backup in Terraform Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/backup.md Defines a daily backup schedule for a PostgreSQL database using a specified S3 destination. ```terraform resource "dokploy_backup" "daily" { database_id = dokploy_database.postgres.id database_type = "postgres" destination_id = dokploy_destination.s3.id schedule = "0 2 * * *" # Daily at 2 AM prefix = "daily-backup" enabled = true } ``` -------------------------------- ### dokploy_backup Resource Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/backup.md Documentation for the dokploy_backup Terraform resource, including schema definitions and usage. ```APIDOC ## dokploy_backup (Resource) ### Description Manages automated backups for Dokploy databases and compose services. Supports scheduling backups to S3-compatible storage destinations. ### Required Parameters - **database** (String) - Database name to backup (for database backups) or identifier (for compose backups). - **destination_id** (String) - ID of the backup destination (S3, MinIO, etc.). - **prefix** (String) - Prefix for backup files. - **schedule** (String) - Cron schedule for backups (e.g., '0 2 * * *' for daily at 2 AM). ### Optional Parameters - **backup_type** (String) - Type of backup: 'database' or 'compose'. - **compose_id** (String) - ID of the compose to backup. - **database_id** (String) - ID of the database to backup. - **database_type** (String) - Type of database: postgres, mysql, mariadb, or mongo. - **enabled** (Boolean) - Whether the backup schedule is enabled. - **keep_latest_count** (Number) - Number of recent backups to keep. - **metadata** (Map of String) - Metadata for the backup configuration. - **service_name** (String) - Name of the service within the compose to backup. ### Read-Only Attributes - **id** (String) - Unique identifier for the backup. ### Import terraform import dokploy_backup.daily "backup-id-123" ``` -------------------------------- ### Configure Compose with Environment Variables Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/compose.md Defines a compose stack sourced from GitHub with custom environment variables provided as a multi-line string. ```terraform resource "dokploy_compose" "with_env" { name = "env-stack" environment_id = dokploy_environment.production.id source_type = "github" github_id = "your-github-app-installation-id" owner = "myorg" repository = "my-stack" branch = "main" compose_path = "./docker-compose.yml" # Environment variables available to compose file env = <<-EOT DATABASE_URL=postgresql://user:pass@db:5432/app REDIS_URL=redis://redis:6379 SECRET_KEY=${var.secret_key} EOT auto_deploy = true deploy_on_create = true } ``` -------------------------------- ### Configure Redis with resource limits Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/redis.md Sets CPU and memory constraints for the Redis container. ```terraform resource "dokploy_redis" "cache" { name = "production-cache" app_name_prefix = "prod-redis" database_password = var.redis_password environment_id = dokploy_environment.production.id # Resource limits memory_limit = "512M" memory_reservation = "256M" cpu_limit = "1000" cpu_reservation = "500" description = "Production Redis with resource limits" } ``` -------------------------------- ### dokploy_ais Data Source Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/data-sources/ais.md Retrieves a list of AI provider configurations including details like API URL, model, and status. ```APIDOC ## Data Source: dokploy_ais ### Description Fetches all AI provider configurations in the current Dokploy organization. ### Read-Only Attributes - **ais** (List) - List of AI configurations. ### Nested Schema for `ais` - **api_url** (String) - The API endpoint URL for the AI provider. - **created_at** (String) - Timestamp when the AI configuration was created. - **id** (String) - Unique identifier for the AI configuration. - **is_enabled** (Boolean) - Whether the AI configuration is enabled. - **model** (String) - The model being used. - **name** (String) - Display name for the AI provider configuration. - **organization_id** (String) - The organization ID this AI configuration belongs to. ``` -------------------------------- ### dokploy_gitea_providers Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/data-sources/gitea_providers.md Fetches the list of Gitea providers configured in Dokploy. ```APIDOC ## Data Source: dokploy_gitea_providers ### Description Fetches the list of Gitea providers configured in Dokploy. ### Schema #### Read-Only - **providers** (Attributes List) - List of Gitea providers. #### Nested Schema for `providers` - **created_at** (String) - The creation timestamp of the provider. - **git_provider_id** (String) - The git provider ID. - **id** (String) - The unique identifier (giteaId) of the Gitea provider. - **name** (String) - The name of the Gitea provider. - **organization_id** (String) - The Dokploy organization ID this provider belongs to. - **provider_type** (String) - The type of provider (gitea). ``` -------------------------------- ### Configure the Dokploy Provider Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/README.md Define the provider source and authentication credentials in your Terraform configuration. ```hcl terraform { required_providers { dokploy = { source = "ahmedali6/dokploy" version = "~> 0.1" } } } provider "dokploy" { host = "https://your-dokploy-instance.com/api" api_key = var.dokploy_api_key # Store securely! } ``` -------------------------------- ### Import Existing Dokploy Backup Source: https://github.com/ahmedali6/terraform-provider-dokploy/blob/main/docs/resources/backup.md Imports an existing backup resource into Terraform state using its unique identifier. ```shell terraform import dokploy_backup.daily "backup-id-123" ```