# Faster rebuilds?

**URL:** https://meta.discourse.org/t/faster-rebuilds/40341
**Category:** Self-hosting
**Created:** [2016年二月29日 16:43 UTC](https://meta.discourse.org/t/faster-rebuilds/40341 "2016-02-29T16:43:06Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![iamntz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iamntz/32/114670_2.png) [@iamntz](https://meta.discourse.org/u/iamntz)
#### Post date: [2016年二月29日 16:43 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/1 "2016-02-29T16:43:06Z")

</div>

Hey guys, I wonder if there is a way to run `./launcher rebuild app` a bit faster. Right now it takes 6-9 minutes to do the whole stuff and i’d like to skip some stuff that looks a bit useless:

These three commands takes a lot of time (about 20-30-60 sec each)

- `cd /var/www/discourse && chown -R discourse /var/www/discourse`
- `cd /var/www/discourse && su discourse -c 'bundle install --deployment --verbose --without test --without development'`
- `cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'`

Compiling assets for each locale is also take about a minute, uglifying js is also takes some time.

Aaaaanyhooow, I was hoping there is a way of semi-rebuilding (?!) the app a bit faster than that. I understand the need of running all of these when you’re installing an update or a new plugin, but sometimes I only need a very quick „restart” for more… special cases:

- update of a SSL cert
- the other day i tried to make it play nice with other sites (following [this](https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247) article) and i had to rebuild couple of times.

PS: `time ./launcher rebuild app --skip-prereqs` is giving only negligible improvements:

```bash
real 5m27.461s
user 0m1.027s
sys 0m0.652s

```

Thanks!

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2016年二月29日 20:05 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/2 "2016-02-29T20:05:01Z")

</div>

If rebuild time is a huge concern to you I would strongly recommend running a dedicated data container

That way you can bootstrap while your existing site is up and running, meaning you only deal with a few seconds of outage when upgrading via launcher

Bundle install is usually very fast when we just ship an image, I plan on having more regular updates to help out here

Assets precompile is the slowest part, we are cosidering pre-bundling assets or possibly adding a caching server or even more aggressive image updates, but nothing is a trivially easy solution

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [2016年三月2日 11:13 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/3 "2016-03-02T11:13:44Z")

</div>

> [@sam](#):
>
> strongly recommend running a dedicated data container

Is there any migration documentation about how to change to this configuration? I thought I saw something at one point but can’t find it in #howto now.

---

<div class="post-metadata">

### Author: ![fantasticfears](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fantasticfears/32/119608_2.png) [@fantasticfears](https://meta.discourse.org/u/fantasticfears)
#### Post date: [2016年三月2日 12:32 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/4 "2016-03-02T12:32:03Z")

</div>

This one. Noted some steps is out-dated:

1. Use `enter` to get into a container.
2. `DISCOURSE_DB_HOST: data` and `DISCOURSE_REDIS_HOST: data`

- link to a container is prefered than IP now.
- define `links` block as follows:

```plaintext
links:
  - link:
      name: data
      alias: data

```

> [@Move from standalone container to separate web and data containers](https://meta.discourse.org/t/how-to-move-from-standalone-container-to-separate-web-and-data-containers/29413):
>
> warning This is an advanced setup. Don’t follow this unless you are experienced with Linux server administration and Docker. You also need to pay close attention to commits to discourse\_docker to make sure you notice if there’s a version bump for postgres or redis. Converting your Current Setup I managed to migrate to two containers. If anyone else needs instructions, this is how it worked for me. The process includes backup, setting up separate web and data containers and restore data. …

---

<div class="post-metadata">

### Author: ![zh99998](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zh99998/32/100179_2.png) [@zh99998](https://meta.discourse.org/u/zh99998)
#### Post date: [2016年三月2日 12:51 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/5 "2016-03-02T12:51:28Z")

</div>

if we don’t stop forum during rebuild (make it read-only if necessary), it will be better?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2016年三月2日 12:55 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/6 "2016-03-02T12:55:15Z")

</div>

Can not be done in a single container setup without major headaches… part of the bootstrap process is spawning the db, you can’t have two instances of a database running at the same time.

---

<div class="post-metadata">

### Author: ![calmh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/calmh/32/115466_2.png) [@calmh](https://meta.discourse.org/u/calmh)
#### Post date: [2016年三月2日 14:20 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/7 "2016-03-02T14:20:42Z")

</div>

How does this work when using a separate data container? Does it run migrations on the data that the old site is still using, potentially breaking the site until the web container is upgraded if the migrations are incompatible?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2016年三月2日 19:42 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/8 "2016-03-02T19:42:24Z")

</div>

Yes, but… We are very careful to keep migrations compatible data wise, even have a pretty elaborate scheme that delays dropping columns when we move them to new tables

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [2016年三月3日 02:38 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/9 "2016-03-03T02:38:06Z")

</div>

> [@fantasticfears](#):
>
> Noted some steps is out-dated

Should this process have copied my data & configuration over? I ran through the steps but got a clean/“fresh” site, so rolled back to the single-container version.

I did a restore from a backup made just before the process, and it seemed to restore everything. So probably this just needs to be made clear. 🙂

---

<div class="post-metadata">

### Author: ![fantasticfears](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fantasticfears/32/119608_2.png) [@fantasticfears](https://meta.discourse.org/u/fantasticfears)
#### Post date: [2016年三月3日 08:59 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/10 "2016-03-03T08:59:55Z")

</div>

I flagged it to ask for wikifing the topic… Let’s amend it 😉

PS: Don’t know whether it’s a right way to use flag..

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2016年三月3日 10:24 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/11 "2016-03-03T10:24:48Z")

</div>

> [@fantasticfears](#):
>
> PS: Don’t know whether it’s a right way to use flag..

Yes, that’s the right way to use the notify moderator feature 😉

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [2016年三月4日 14:24 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/12 "2016-03-04T14:24:37Z")

</div>

> [@sam](#):
>
> That way you can bootstrap while your existing site is up and running, meaning you only deal with a few seconds of outage when upgrading via launcher

Can you say a bit more about how this process works in your mind?

After switching to the multi-container scenario, I just did a `./launcher rebuild web_only` but my downtime was the same. Clearly I need more coffee still this morning.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2016年三月4日 16:12 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/13 "2016-03-04T16:12:24Z")

</div>

```
./launcher bootstrap web_only

```

Start outage

```
./launcher destroy web_only
./launcher start web_only

```

End outage

---

<div class="post-metadata">

### Author: ![mastef](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mastef/32/74689_2.png) [@mastef](https://meta.discourse.org/u/mastef)
#### Post date: [2017年七月4日 06:21 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/14 "2017-07-04T06:21:33Z")

</div>

Is there any way to skip the whole uglify and compressing of assets & locales during bootstrap if the assets already exist?

Maybe it would make sense to have a dedicated assets volume and/or a comparison of checksums of input files and output filenames before a recompile is attempted.

Or utilising the cache of a docker image build on bootstrap, which could cache the whole git pull / install process unless git repo changes ( [https://stackoverflow.com/a/39278224](https://stackoverflow.com/a/39278224) )

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2017年七月4日 07:22 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/15 "2017-07-04T07:22:26Z")

</div>

> [@mastef](#):
>
> comparison of checksums of input files and output filenames before a recompile is attempted.

Could checksums be used here @sam or @falco?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2017年七月4日 11:48 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/16 "2017-07-04T11:48:14Z")

</div>

Yes, I discussed this with @eviltrout in the past, we would need a post build step, an asset server and to customize asset precompile

I estimate it would take less than 2 days to setup

---

<div class="post-metadata">

### Author: ![Philip\_Freeman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/philip_freeman/32/75284_2.png) [@Philip\_Freeman](https://meta.discourse.org/u/Philip_Freeman)
#### Post date: [2017年七月14日 18:08 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/17 "2017-07-14T18:08:39Z")

</div>

In the event of a failure in the start method, how can you roll back to the previous container?

---

<div class="post-metadata">

### Author: ![Peter\_Backgren](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/peter_backgren/32/66263_2.png) [@Peter\_Backgren](https://meta.discourse.org/u/Peter_Backgren)
#### Post date: [2017年八月4日 14:26 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/18 "2017-08-04T14:26:07Z")

</div>

I must admit this has been a bit of a headache for me as well.

I just went https (smooth process, great) and decided to change the dated “out” email at the same time (basically gmail → gandi). 4h later and umpteen rebuilds later I’m just reverting to the dated one (at least for today). 10 minutes per rebuild is not fun. Not to mention the time figuring out how to cleanup when I run out of space. I’ll be faster next time 😉 .

Do all the settings in app.yml **really** require a rebuild? One would imagine changing email settings would just change something in one place.

---

<div class="post-metadata">

### Author: ![Tom\_Newsom](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tom_newsom/32/115981_2.png) [@Tom\_Newsom](https://meta.discourse.org/u/Tom_Newsom)
#### Post date: [2017年八月4日 14:38 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/19 "2017-08-04T14:38:50Z")

</div>

If you change something in `env:` or `expose:` then you can just do `./launcher restart app`

---

<div class="post-metadata">

### Author: ![Peter\_Backgren](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/peter_backgren/32/66263_2.png) [@Peter\_Backgren](https://meta.discourse.org/u/Peter_Backgren)
#### Post date: [2017年八月4日 14:43 UTC](https://meta.discourse.org/t/faster-rebuilds/40341/20 "2017-08-04T14:43:43Z")

</div>

Ok, I’m sure there is somewhere where I can figure out what belongs to which area?

I really try not to ask until I’ve investigated (read: suffered) but this time I apparently/probably should have…

Edit: Ok, looking at app.yml gave me a clear answer, never mind 😃 .

Friday and 7h of configuring is not good for anyone. Luckily I’m not 15 anymore, 24h configuring…

[下一頁](https://meta.discourse.org/t/faster-rebuilds/40341.md?page=2)
