Bridge terraform-provider-dokploy into a Pulumi provider
18 resources and 5 data sources mapped into the dokploy:index module, with SDKs generated for TypeScript, Python, Go and .NET.
This commit is contained in:
59
examples/python/__main__.py
Normal file
59
examples/python/__main__.py
Normal file
@@ -0,0 +1,59 @@
|
||||
"""A small Dokploy stack: a project, a Postgres instance and a public app.
|
||||
|
||||
export DOKPLOY_HOST=https://dokploy.example.com
|
||||
export DOKPLOY_API_KEY=...
|
||||
pulumi up
|
||||
"""
|
||||
|
||||
import pulumi
|
||||
import pulumi_dokploy as dokploy
|
||||
import pulumi_random as random
|
||||
|
||||
shop = dokploy.Project(
|
||||
"shop",
|
||||
name="shop",
|
||||
description="Storefront and its backing services",
|
||||
)
|
||||
|
||||
db_password = random.RandomPassword("postgres", length=32, special=False)
|
||||
|
||||
db = dokploy.Postgres(
|
||||
"db",
|
||||
name="shop-db",
|
||||
environment_id=shop.default_environment_id,
|
||||
docker_image="postgres:16-alpine",
|
||||
database_name="shop",
|
||||
database_user="shop",
|
||||
database_password=db_password.result,
|
||||
memory_limit="1g",
|
||||
)
|
||||
|
||||
# Dokploy resolves service names on the shared Docker network, so the database
|
||||
# is reachable by its generated app_name.
|
||||
database_url = pulumi.Output.all(db.app_name, db_password.result).apply(
|
||||
lambda args: f"DATABASE_URL=postgresql://shop:{args[1]}@{args[0]}:5432/shop"
|
||||
)
|
||||
|
||||
api = dokploy.Application(
|
||||
"api",
|
||||
name="api",
|
||||
environment_id=shop.default_environment_id,
|
||||
source_type="docker",
|
||||
docker_image="ghcr.io/acme/api:1.4.0",
|
||||
env=database_url,
|
||||
replicas=2,
|
||||
memory_limit="512m",
|
||||
)
|
||||
|
||||
dokploy.Domain(
|
||||
"api",
|
||||
application_id=api.id,
|
||||
domain_type="application",
|
||||
host="api.example.com",
|
||||
port=3000,
|
||||
https=True,
|
||||
certificate_type="letsencrypt",
|
||||
)
|
||||
|
||||
pulumi.export("project_id", shop.id)
|
||||
pulumi.export("api_id", api.id)
|
||||
Reference in New Issue
Block a user