Toolkit

DockerCommands extends AbstractCommands
in package

FinalYes

Provides commands to update docker-compose.yml based on project's configurations.

Table of Contents

Constants

DC_YML_FILE  = 'docker-compose.yml'
DC_YML_FILE_PREVIOUS  = 'docker-compose.yml.prev'
DEV_SUFFIX  = '-dev'
OPTS_YML_FILE  = '.opts.yml'

Methods

dockerRefreshConfiguration()  : int
Update docker-compose.yml file based on project's configurations.
getConfigurationFile()  : mixed
Path to YAML configuration file containing command defaults.
getJson()  : array<string|int, mixed>
Returns the JSON parsed content.
getWorkingDir()  : string
Returns the current working directory.
isWebsiteInstalled()  : bool
Check if the website is installed.
getBin()  : string
Validate and return the path to given bin.
getBinPath()  : string
Return the path to given bin.
getConfigValue()  : mixed
{@inheritdoc}
getNodeBin()  : string
Validate and return the path to given bin from node packages.
getNodeBinPath()  : string
Return the path to given bin from node packages.
isJunit()  : bool
Check whether Junit option is being used, or env var is set.
isSimulating()  : bool
Check if current command is being executed with option simulate.
taskExecute()  : mixed
Execute a command.
taskProcess()  : mixed
Process the file.
taskReplaceBlock()  : mixed
Replace block in a file.
backupDockerComposeFile()  : void
Backup current docker-compose.yml to docker-compose.yml.prev.
copyDockerComposeDefaultToProject()  : void
Copy ./resources/docker/default.yml file to docker-compose.yml inside project root directory.
extractMajorMinorVersion()  : string
Converts from semantic version to "major.minor" version.
getFinalImages()  : array<string|int, mixed>
Get final images to update docker-compose.yml.
getProjectPhpFromWebsite()  : array<string|int, mixed>
Returns the Project's php service version information from the endpoint.
getServiceDetailsFromResources()  : array<string|int, mixed>
Return the details for a service from ./resources/docker.
getServiceImage()  : string
Get service image with version.
getServicesImagesFromDockerCompose()  : array<string|int, mixed>
Get array of services with images and versions from docker-compose.yml.
getServicesVersionsFromRequirements()  : array<string|int, mixed>
Get final services names with versions from requirements.
getWarningMessages()  : array<string|int, mixed>
Get warning messages for versions on .opts.yml that not respect the minimum requirements.
getWebsiteRequirements()  : array<string|int, mixed>
Returns the toolkit requirements from the endpoint.
removeUnusedDcServices()  : array<string|int, mixed>
Remove services that do not exist in project info, requirements or .opts.yml.
updateDockerComposeFile()  : void
Update docker-compose.yml.
writeWarningMessages()  : void
Write all available warning messages.

Constants

DC_YML_FILE_PREVIOUS

private mixed DC_YML_FILE_PREVIOUS = 'docker-compose.yml.prev'

Methods

dockerRefreshConfiguration()

Update docker-compose.yml file based on project's configurations.

public dockerRefreshConfiguration() : int

This command allows developers to update the docker-compose.yml file taking in consideration:

  • The service versions on the .opts.yml file (php_version, mysql_version, selenium_version, solr_version).
  • The service versions currently on client's production.
  • Quality Assurance minimum version requirements and defaults (https://digit-dqa.fpfis.tech.ec.europa.eu/requirements).

Notes: If a version is provided in .opts.yml, this one must be used (a warning message is displayed if the versions are non-compliant or outdated with Quality Assurance requirements) If no opts.yml is provided, the newer version from QA requirements or project production version will be used. In case of some information is not available, the images will be updated based on Quality Assurance default values.

Tags
command

docker:refresh-configuration

aliases

dk-rc

throws
Exception
Return values
int

getConfigurationFile()

Path to YAML configuration file containing command defaults.

public getConfigurationFile() : mixed

Command classes should implement this method.

getJson()

Returns the JSON parsed content.

public getJson(string $filename[, mixed $throwException = true ]) : array<string|int, mixed>
Parameters
$filename : string
$throwException : mixed = true
Return values
array<string|int, mixed>

getWorkingDir()

Returns the current working directory.

public getWorkingDir() : string
Return values
string

The current working directory.

isWebsiteInstalled()

Check if the website is installed.

public isWebsiteInstalled() : bool
Return values
bool

getBin()

Validate and return the path to given bin.

protected getBin(string $name) : string
Parameters
$name : string

The bin to look for.

Tags
throws
TaskException
Return values
string

The bin path.

getBinPath()

Return the path to given bin.

protected getBinPath(string $name) : string
Parameters
$name : string
Return values
string

The path to given binary.

getConfigValue()

{@inheritdoc}

protected getConfigValue(mixed $key[, mixed $default = null ]) : mixed
Parameters
$key : mixed
$default : mixed = null

getNodeBin()

Validate and return the path to given bin from node packages.

protected getNodeBin(string $name) : string
Parameters
$name : string

The bin to look for.

Tags
throws
TaskException
Return values
string

The bin path.

getNodeBinPath()

Return the path to given bin from node packages.

protected getNodeBinPath(string $name) : string
Parameters
$name : string
Return values
string

The path to given binary.

isJunit()

Check whether Junit option is being used, or env var is set.

protected isJunit() : bool
Return values
bool

isSimulating()

Check if current command is being executed with option simulate.

protected isSimulating() : bool
Return values
bool

True if using --simulate, false otherwise.

taskExecute()

Execute a command.

protected taskExecute(array<string|int, mixed> $tasks) : mixed
Parameters
$tasks : array<string|int, mixed>

An array with tasks to execute.

taskProcess()

Process the file.

protected taskProcess(string $source[, string $destination = '' ]) : mixed
Parameters
$source : string

The source file to process.

$destination : string = ''

The destination file.

taskReplaceBlock()

Replace block in a file.

protected taskReplaceBlock([string $filename = '' ]) : mixed
Parameters
$filename : string = ''

The file to process.

backupDockerComposeFile()

Backup current docker-compose.yml to docker-compose.yml.prev.

private backupDockerComposeFile() : void

copyDockerComposeDefaultToProject()

Copy ./resources/docker/default.yml file to docker-compose.yml inside project root directory.

private copyDockerComposeDefaultToProject() : void

extractMajorMinorVersion()

Converts from semantic version to "major.minor" version.

private extractMajorMinorVersion(string $version) : string
Parameters
$version : string

The version to convert.

Return values
string

getFinalImages()

Get final images to update docker-compose.yml.

private getFinalImages(mixed $requirements, mixed $websiteRequirements, mixed $optsFileContent) : array<string|int, mixed>
Parameters
$requirements : mixed

The requirements

$websiteRequirements : mixed

The website requirements.

$optsFileContent : mixed

The .opts.yml content.

Return values
array<string|int, mixed>

getProjectPhpFromWebsite()

Returns the Project's php service version information from the endpoint.

private getProjectPhpFromWebsite(string $projectId) : array<string|int, mixed>
Parameters
$projectId : string

The project id.

Return values
array<string|int, mixed>

getServiceDetailsFromResources()

Return the details for a service from ./resources/docker.

private getServiceDetailsFromResources(string $serviceName) : array<string|int, mixed>
Parameters
$serviceName : string

The service name.

Return values
array<string|int, mixed>

getServiceImage()

Get service image with version.

private getServiceImage(string $service, string $image, string $version) : string
Parameters
$service : string

The service.

$image : string

The image.

$version : string

The version.

Return values
string

getServicesImagesFromDockerCompose()

Get array of services with images and versions from docker-compose.yml.

private getServicesImagesFromDockerCompose(array<string|int, mixed> $dcContent) : array<string|int, mixed>
Parameters
$dcContent : array<string|int, mixed>

The docker-compose content.

Return values
array<string|int, mixed>

getServicesVersionsFromRequirements()

Get final services names with versions from requirements.

private getServicesVersionsFromRequirements(array<string|int, mixed> $content) : array<string|int, mixed>
Parameters
$content : array<string|int, mixed>

The content to check.

Return values
array<string|int, mixed>

getWarningMessages()

Get warning messages for versions on .opts.yml that not respect the minimum requirements.

private getWarningMessages(mixed $optsFileContent, mixed $websiteRequirements) : array<string|int, mixed>
Parameters
$optsFileContent : mixed

The .opts.yml content.

$websiteRequirements : mixed

The website requirements.

Return values
array<string|int, mixed>

getWebsiteRequirements()

Returns the toolkit requirements from the endpoint.

private getWebsiteRequirements() : array<string|int, mixed>
Return values
array<string|int, mixed>

removeUnusedDcServices()

Remove services that do not exist in project info, requirements or .opts.yml.

private removeUnusedDcServices(array<string|int, mixed> $dcServices, array<string|int, mixed> $finalServicesImages) : array<string|int, mixed>
Parameters
$dcServices : array<string|int, mixed>

The services.

$finalServicesImages : array<string|int, mixed>

The final services.

Return values
array<string|int, mixed>

updateDockerComposeFile()

Update docker-compose.yml.

private updateDockerComposeFile(array<string|int, mixed> $dcContent, array<string|int, mixed> $finalServicesImages) : void
Parameters
$dcContent : array<string|int, mixed>

The docker-compose content.

$finalServicesImages : array<string|int, mixed>

The services images.

writeWarningMessages()

Write all available warning messages.

private writeWarningMessages(array<string|int, mixed> $messages) : void
Parameters
$messages : array<string|int, mixed>

Messages to print.


        
On this page

Search results