简体   繁体   English

根据用户创建在Heroku上自动部署应用

[英]Automatically Deploy App on Heroku Based on User Creation

I have a Multi-Tenant Django Application working with Postgres on Heroku. 我在Heroku上有一个与Postgres一起使用的多租户Django应用程序。 Is there a way to actually instantiate a new dyno/db/subdomain based on when a new User is created on my application? 有没有一种方法可以根据在应用程序上创建新用户的时间实际实例化新的dyno / db / subdomain?

This is highly dependent on how your multi-tenancy is being achieved. 这在很大程度上取决于如何实现多租户。

If you haven't already built multi-tenancy into your application I encourage you to look at something like django-tenants , which adds multitenancy support based on subdomains and PostgreSQL schemas. 如果您尚未在应用程序中构建多租户,则建议您看一下django-tenants东西,它添加了基于子域和PostgreSQL模式的多租户支持。 If that's not a good fit you can explore other similar libraries . 如果不合适,则可以探索其他类似的库

Once you've set up django-tenants there's not much more to do on the Django side. 设置django-tenants ,在Django方面没有更多的工作要做。 It all be comes configuration. 全部都是配置。 Requests to configured subdomains will be routed to the appropriate shared or tenant database schema. 对配置的子域的请求将被路由到适当的共享或租户数据库架构。

But those requests have to make it to your application. 但是这些请求必须将其添加到您的应用程序中。 That's where DNS comes in, ideally using wildcard subdomains. 这就是DNS出现的地方,理想情况下使用通配符子域。

First, add *.your-domain.tld to your app's domains on the Heroku side: 首先,在Heroku端*.your-domain.tld添加到应用程序的域中

heroku domains:add *.your-domain.tld

Next, add a wildcard CNAME entry with your DNS provider¹. 接下来,与您的DNS提供商¹添加通配符CNAME条目。 The exact mechanics of how to do this will vary from provider to provider. 提供商的确切机制各不相同。 You've said you're moving to DNSimple, and it looks like they support wildcard CNAME records using * . 您已经说过要迁移到DNSimple,并且看起来它们支持使用*通配符CNAME记录


¹Unfortunately, some DNS providers like GoDaddy don't support wildcard CNAME entries . ¹很遗憾, 某些DNS提供商(例如GoDaddy)不支持通配符CNAME条目 In that case you'll have to individually create each CNAME record. 在这种情况下,您将必须分别创建每个CNAME记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM