Docker compose does not feature the required functionality. Discourse’s docker file templating construction allows for flexible docker results. With compose all you have is a possible set of fixed Dockefiles which can result in a bunch of containers.
In my Discourse setup I use a single container with Discourse and nginx using a UNIX socket. PostgreSQL and Redis are a service on the host. That is quite a deviation from the the default setup, but it is possible out of the box.
It is partially possible with compose, maybe by using the rather ill engineered profile feature. But even then it is rather messy. Or you would need to deliver different compose files for each variation.
You are just moving the problem.
A clean compose setup for Discourse would be the following services in separate containers:
- Discourse
- nginx
- PostgreSQL
- Redis
Disocurse and nginx need to share a volume, no biggy.
PostgreSQL and Redis… those are things you might want to host elsewhere, and not have a Discourse specific container for it. And now docker compose become an issue docker compose up -d
will launch your undesired PostgreSQL. Ok, so we make it docker compose --profile postgresql up -d
to launch the basic discourse setup, and a postgresql container. docker compose --profile postgresql --profile redis up -d
for the “full” self contained Discourse container setup. You better not forger a --profile ...
argument, because then you have more issues.
So for better UX, you make a launcher to take care of creating the desired docker compose command. Now we are kind of back where we are. Except that modifications to the nginx container are not possible yet. So I need a nginx-http container and nginx-unix container which should be mutually exclusive? …
Sure the plugin management could be better, but doing this with docker compose, that’ll be hell.