How to collect all static assets (js, css) used by discourse

That’s a good question, but I don’t have a good answer for you.

The configuration system used inside the container is:
https://github.com/discourse/pups

The README there describes how the hooks work generally. The specific hooks available to use depend on how your instance is setup – the main app.yml will have includes one of more template. In most cases, one of those is web.template.yml:

That’s where the assets_precompile hook is defined (on [L159] as I type this). Per the pups documentation, you can run other commands before or after that completes with before_assets_precompile and after_assets_precompile respectively.

The commands are run inside the docker container, so you don’t have to do anything for that.

The cd: directive can point right to /var/www/discourse/public/assets/ and each line in cmd gets run from that directory. (Warning: each line in a cmd array is run in a separate shell, like in a Makefile).

I’m not sure if the contents of /var/www/discourse/public/assets/ would persist between builds, so you might have to create the local git repository and force push every time. The “more correct” solution might be to define a docker volume in app.yml for the assets directory on a docker volume defined in app.yml like the others and persist outside the container.