dnephin / dobi

A build automation tool for Docker applications
https://dnephin.github.io/dobi/
Apache License 2.0
310 stars 36 forks source link

Elaborate on rails example #118

Open OnkelTem opened 6 years ago

OnkelTem commented 6 years ago

I'm personally not a rails programmer but since I can't start with Dobi for months I thought that I might be missing some important point about Dobi and which is actually hidden somewhere in the rails example. I tried to read its code, again and again but it's still cryptic for me. So would someone explain step by step how does it work?

Specifically:

Also it's unclear when and which services are really launched and when they are stopped. As far as I understand Dobi is unable to run any services, so how would I initialize a database running in a container?

dnephin commented 6 years ago

What does empty-db-env do?

This is maybe not the best name. I think maybe it should be called empty-db. It is just an "empty" postgresql database. Empty meaning "no fixture data".

It just starts the postgresql database. This would be changed to service=emptydb when service resources exist.

Why export-models takes and executes a script from filesystem (db/export.sh) and not incorporate it in itself if it's gonna use it?

I'm not sure what you're asking here.

How would application reference postgresql via postgres hostname if it's not declared anywhere?

Yes, this is a bit hidden. It has to do with how "docker user defined networks" work. Contains on that network can have aliases which can be used as hostnames. docker-compose runs the empty-db.yml file, which creates a "user defined network" and sets the postgres alias.

After that, any other container that joins the network can use that alias. So in export-models net-mode: '{project}export_default' tells dobi to put the container on the same network, so it is able to use that alias.

How simply by declaring net-mode in export-models job it's gonna "connect" somewhere and where it's going to connect actually?

net-mode will accept the name of the network. The network that was created by docker-compose is called {project}export_default. So it tells it to join that network when it creates the container.

If you do docker network ls when it's running you will see that network listed.

Also it's unclear when and which services are really launched and when they are stopped.

They are stopped when dobi exits. They are started based on the task dependency order, like all other tasks.

so how would I initialize a database running in a container?

That is exactly what is happening in this example. Hopefully I've been able to explain it a bit better, but let me know if you have more questions.

OnkelTem commented 6 years ago

Thank you very much for the explanations. (Offtopic: Sometimes it seems to me that we're the only people on Earth dedicating Dobi our time :) Dobi definitely needs more promotion)

While I was waiting for an answer I've learned something myself. I'm going to share soon my dobi.yaml which I was cooking last weekends for others to learn from it and to fix some ugly parts maybe.