Toolkit

DockerCommands extends AbstractCommands
in package

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

Table of Contents

DC_YML_FILE  = 'docker-compose.yml'
DC_YML_FILE_PREVIOUS  = 'docker-compose.yml.prev'
DEV_SUFFIX  = '-dev'
OPTS_YML_FILE  = '.opts.yml'
dockerRefreshConfiguration()  : int
Update docker-compose.yml file based on project's configurations.
getConfigurationFile()  : string
Path to YAML configuration file containing command defaults.
getWorkingDir()  : string
Returns the current working directory.
initializeRuntimeConfiguration()  : mixed
Command initialization.
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.
isSimulating()  : bool
Check if current command is being executed with option simulate.
taskExecute()  : mixed
Execute a command.
taskProcess()  : Process|CollectionBuilder
Process the file.
taskReplaceBlock()  : ReplaceBlock|CollectionBuilder
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
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
getWebsiteProjectInformation()  : array<string|int, mixed>|array<string|int, string>
Returns the Project's php service version information from the endpoint.
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://webgate.ec.europa.eu/fpfis/qa/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() : string

Command classes should implement this method.

Return values
string

getWorkingDir()

Returns the current working directory.

public getWorkingDir() : string
Return values
string

The current working directory.

initializeRuntimeConfiguration()

Command initialization.

public initializeRuntimeConfiguration() : mixed
Tags
hook

pre-command-event *

Return values
mixed

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
Return values
mixed

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.

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.

Return values
mixed

taskProcess()

Process the file.

protected taskProcess(string $source[, string $destination = '' ]) : Process|CollectionBuilder
Parameters
$source : string

The source file to process.

$destination : string = ''

The destination file.

Return values
Process|CollectionBuilder

taskReplaceBlock()

Replace block in a file.

protected taskReplaceBlock([string $filename = '' ]) : ReplaceBlock|CollectionBuilder
Parameters
$filename : string = ''

The file to process.

Return values
ReplaceBlock|CollectionBuilder

backupDockerComposeFile()

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

private backupDockerComposeFile() : void
Return values
void

copyDockerComposeDefaultToProject()

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

private copyDockerComposeDefaultToProject() : void
Return values
void

extractMajorMinorVersion()

Converts from semantic version to "major.minor" version

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

getFinalImages()

Get final images to update docker-compose.yml

private getFinalImages( $requirements,  $websiteRequirements,  $optsFileContent) : array<string|int, mixed>
Parameters
$requirements :
$websiteRequirements :
$optsFileContent :
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
Return values
array<string|int, mixed>

getServiceImage()

Get service image with version

private getServiceImage(string $service, string $image, string $version) : string
Parameters
$service : string
$image : string
$version : string
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>
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>
Return values
array<string|int, mixed>

getWarningMessages()

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

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

getWebsiteProjectInformation()

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

private getWebsiteProjectInformation(string $projectId) : array<string|int, mixed>|array<string|int, string>
Parameters
$projectId : string
Tags
throws
Exception
Return values
array<string|int, mixed>|array<string|int, string>

getWebsiteRequirements()

Returns the toolkit requirements from the endpoint.

private getWebsiteRequirements() : array<string|int, mixed>
Tags
throws
Exception
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>
$finalServicesImages : array<string|int, mixed>
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>
$finalServicesImages : array<string|int, mixed>
Return values
void

writeWarningMessages()

Write all available warning messages

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

Search results