D2C uses three deployment phases: building, deploying, and running. D2C may execute all three of them one after another, or just the necessary one. For example, you may want to rebuild a base container with an upgraded Node release and run it with the same source code and data. Or you may want to update the source code and reload your application to pick up these changes.
It is a process of building the container image for your application. It includes downloading base docker OS images for the application, installing, and configuring necessary packages. There is no access to application sources in this step. All modifications done in this step are stored inside the container image; no data is saved to external volume. Treat this step like preparing a server for running your application. You use installCommands to run commands in this step.
It is a process of preparing your application to be ready to run. During this step, you have access to application source codes and data volume, but no changes will be saved to the container image. You should use this step, for example, to compile CSS, minify JS, install local code dependencies, make the initial database population, etc.
The deployment process runs in temporary containers with its own source code copy but the same data volume. The source code volume from this temporary container is placed into the main container afterwards. This allows you to achieve near zero downtime deployment by preparing a new version of code while the previous one is still running online; at the same time, if you need to migrate the current database to a new version, you have access to the live data volume. Depending on your preferred deployment process, you may wish to stop the current application first (in case of DB migration), or to keep it running and just swap the source code after the preparation process in the temporary container is completed. You use deployCommands to run commands in this step.
After the deployment process is completed, the temporary container is removed. So in this step, you may change only the source code or data volume. Any changes that are made in other locations (e.g., installing npm-packages globally) will be lost. Remember to use the build step to create container-wide changes.
In this step, the app container is started with source code and data volumes mounted. All networking is being properly configured, ports published, and DNS set up. The container image created during the build step is used to spin up the container. You use startCommand to start your application.
You should usually modify runCommand only for custom applications like Node, Python, etc. Standard applications like database engines and web servers provided by D2C use predefined commands.
Interacting with your application
There is a possibility of executing a command inside a running application container. For example, you may want to compress your data when your application doesn't support this function but some packages inside a container do. You use execCommand to achieve this.