Skip to content

[5] Command script

Cristian Marcelo de Picciotto edited this page Mar 1, 2026 · 21 revisions

Introduction

The main idea of this document is to explain how this tool is structured and how it works.

The .dockgento_profile file

To use this tool, you need to create a .dockgento_profile file in the folder where the tool will be executed. This file allows you to define environment variables that customize how the environment is generated. The .dockgento_profile file contains environment variables manually defined by the user. The script also generates additional variables based on the current host's specifications, such as the number of CPUs or available RAM.

Note

The idea is that .dockgento_profile will have environment variables that should be manually defined, and the script will generate environment variables that could be obtained/calculated.

All these environment variables (those defined in the .dockgento_profile file and those generated by the script) are combined to create .env files. These .env files are the common ones used by a Docker Compose environment to configure the services and control the behavior of the applications running within them (for instance, this one or this one).

Note

Environment variables in the .dockgento_profile file, as well as those generated by the script, use the SCRIPT_ prefix. This distinction helps differentiate them from other variables, such as:

Commands

This tool provides several commands:

This is the most important command, as it performs four key tasks:

Note

You can start the environment simply by running dockgento up, which is a wrapper of docker compose up -d. The script automatically creates a COMPOSE_FILE environment variable, which tells Docker Compose which files to use. Additionally, the cron service is started based on the COMPOSE_PROFILES environment variable, which the script generates by considering the SCRIPT_COMPOSE_PROFILES defined in the .dockgento_profile file.

This command executes the cli service and uses its init script to install a Magento platform.

The main purpose of this command is to copy the Dockerfile that will be used for building the production web image.

Additionally, if this command receives a DB dump path related to the platform, it normalizes it and deploys it into the environment.

Basically, this command is a wrapper of docker compose up -d. It was implemented because, for production environments, it is required to define a new project name for each release. This is because we are sharing the newly released source code by named volume (docroot) between containers. If we release new source code, it is required to recreate the volume so the old content does not override the released one. To avoid having to recreate the volume, we set a new project name every time the environment is started. In that way, the docroot volume will be prefixed with a new project name each time.

Note

Because the project name is generated using the current epoch time prefixed with release_, an example of the volume name could be: release_1772393938_docroot.

Important

This approach has the advantage of creating new resources each time a new release is deployed, so it is easier to do rollbacks. However, this is also a disadvantage because every release consumes disk space and it is important to purge things from time to time.

Clone this wiki locally