Completed
Push — master ( e28e5a...6fa56b )
by Julien
02:03
created

BuildDockerfileJob   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 12
dl 0
loc 28
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 1
1
<?php
2
3
4
namespace TheAentMachine\AentGitLabCI\GitLabCI\Job;
5
6
use TheAentMachine\AentGitLabCI\Exception\JobException;
7
8
class BuildDockerfileJob extends AbstractBuildJob
9
{
10
    /**
11
     * BuildDockerfileJob constructor.
12
     * @param string $envName
13
     * @param string $serviceName
14
     * @param string $registryDomainName
15
     * @param string $projectGroup
16
     * @param string $projectName
17
     * @param string $branch
18
     * @throws JobException
19
     */
20
    public function __construct(string $envName, string $serviceName, string $registryDomainName, string $projectGroup, string $projectName, string $branch)
21
    {
22
        parent::__construct($envName, $serviceName);
23
        $this->isVariableEnvironment = false;
24
        $this->dockerImageName = "$registryDomainName/$projectGroup/$projectName:$branch";
25
26
        $this->image = 'docker:git';
27
        $this->services[] = 'docker:dind';
28
        $this->variables['DOCKER_DRIVER'] = 'overlay2';
29
        $this->script = [
30
            'docker login -u ${CI_DEPLOY_USER} -p ${CI_DEPLOY_PASSWORD} ${REGISTRY_DOMAIN_NAME}',
31
            'docker build -t ' . $this->dockerImageName . ' .',
32
            'docker push ' . $this->dockerImageName
33
        ];
34
35
        $this->addOnly($branch);
36
    }
37
}
38