Forward: Question on understanding source code

Responding to a direct message question sent to me:

I have read the source code. I couldn’t find the part how it communicates with the OS and docker. Can you share links for related files?

First off, I should mention that I recommend using an IDE that allows for quick navigation to defined variables, methods, classes, etc. I use RubyMine, but there are many others that can support this through plugins (vscode, sublime, vim, emacs, etc). That way as you’re exploring the source code, you can quickly find where something is defined. Even GitHub’s web UI has some limited support for this.

There is no single file that handles all docker communication. Instead, you’ll want to inspect the Deployment::Container model to understand all it’s attributes and methods.

To see how a container is provisioned, please reference this doc: controller/ at main · ComputeStacks/controller · GitHub – each bullet point is a separate class/file.

If the class ends in Service , then you’ll find it under app/services. If it ends in Worker , then you’ll find it under app/workers.

To answer your question about how we talk to Docker, we use a combination of services, workers, and model methods.


Creating a container:

This is kicked off by our ContainerWorkers::ProvisionWorker job: controller/provision_worker.rb at main · ComputeStacks/controller · GitHub

Container is built here:

For a container, runtime_config is defined here:

For an SFTP/SSH container, it’s defined here:

Once it’s built, we start it using the StartWorker:

Running commands inside of a container

1 Like