# Theme automation

**URL:** https://meta.discourse.org/t/theme-automation/228579
**Category:** Development
**Tags:** unsupported-install
**Created:** [May 31, 2022, 10:43am UTC](https://meta.discourse.org/t/theme-automation/228579 "2022-05-31T10:43:11Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![gabriele\_fraracci](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gabriele_fraracci/32/262079_2.png) [@gabriele\_fraracci](https://meta.discourse.org/u/gabriele_fraracci)
#### Post date: [May 31, 2022, 10:43am UTC](https://meta.discourse.org/t/theme-automation/228579/1 "2022-05-31T10:43:12Z")

</div>

Hi all, Im new here 🙂  
So Im running a Dockerized version of bitnami Discourse ( the latest one ) on a Kubernetes cluster, really seems to be a great project. However Im facing a kind of problem trying to autmate a theme installation. Essentially I need to build, deploy, run and configure this docker image from a CICD, so at the very first login everything is ready. About the configuration stuffs there is the customized theme installation. As far as a could understand from several forums and docs there is no a native way to install it programmatically, i found just a click by click guide ( correct me if Im wrong pls ).

My first idea was to add the theme files “manually” in the Discourse file systems via k8s, but as I can see Discourse manage its files in a strange way, renaming them according to its own internal logic and making it impossibile to predict.

Looking in more detail i found this great cli called [discourse\_theme](https://github.com/discourse/discourse_theme) , the problem here is that I would still need to generate an api key from discourse first, otherwise it cannot work ( again… correct me if Im wrong ).  
So in the end Ive a couple questions:  
first, is there a different/native way to install programmatically a theme in Discourse that I missed?  
and on the other hand, is there a way to get an api key from discourse from a script?  
and at the end, does anyone know some kubernetees trick to workaround this kind of issue?

Many thanks in advance

best regards

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [May 31, 2022, 6:04pm UTC](https://meta.discourse.org/t/theme-automation/228579/2 "2022-05-31T18:04:10Z")

</div>

> [@gabriele\_fraracci](#):
>
> is there a different/native way to install programmatically a theme in Discourse that I missed?

That’s supported when using our [official install](https://meta.discourse.org/t/142537?silent=true) method: [Install a Theme programatically](https://meta.discourse.org/t/installing-a-theme-programatically/191843)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 31, 2022, 6:27pm UTC](https://meta.discourse.org/t/theme-automation/228579/3 "2022-05-31T18:27:37Z")

</div>

I think that the only solution is to build an image that includes the plugins that you want, push it to a docker repo, launch it with the appropriate ENV variables, and at some point see that the database is migrated and assets precompiled and pushed to S3 on (at least) the first time the image is run. You might want to migrate once with `SKIP_POST_DEPLOYMENT_MIGRATIONS` set while the old image is running and then again after the new image has launched and the old ones have shut down with `SKIP_POST_DEPLOYMENT_MIGRATIONS` turned off or run the `db:ensure_post_migrations` rake task.

> [@gabriele\_fraracci](#):
>
> is there a way to get an api key from discourse from a script?

You can run a rake task in one of your running images, something like

```
         rake api_key:create_master['description of key']

```

> [@gabriele\_fraracci](#):
>
> does anyone know some kubernetees trick to workaround this kind of issue?

The above might be enough to get you a bit further. I’ve run kubernetes instances for clients on GCP and AWS in the past. I was never 100% happy with how it worked (it worked perfectly from the client’s perspective, it just wasn’t very elegant from mine, but it wasn’t so inelegant that I bothered to fix it, either!). I don’t have much more to offer here, but feel free to contact me directly if you need more help.
