Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Argument.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Kiboko\Component\Dockerfile;

final readonly class Argument implements Variable
{
public function __construct(
public string $name,
) {
}

public function __toString()
{
return "\${{$this->name}}";
}
}
4 changes: 2 additions & 2 deletions src/Dockerfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ final class Dockerfile implements \IteratorAggregate, \Countable, FileInterface,
/** @var iterable|Dockerfile\LayerInterface[] */
private iterable $layers;

public function __construct(null|Dockerfile\LayerInterface ...$layers)
public function __construct(null|LayerInterface ...$layers)
{
$this->layers = $layers;
}

public function push(Dockerfile\LayerInterface ...$layers): void
public function push(LayerInterface ...$layers): void
{
array_push($this->layers, ...$layers);
}
Expand Down
23 changes: 23 additions & 0 deletions src/Dockerfile/Arg.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Kiboko\Component\Dockerfile\Dockerfile;

final readonly class Arg implements LayerInterface, \Stringable
{
public function __construct(
private string $name,
private ?string $defaultValue = null,
) {
}

public function __toString(): string
{
if (null !== $this->defaultValue) {
return sprintf('ARG %s=%s', $this->name, $this->defaultValue);
}

return sprintf('ARG %s', $this->name);
}
}
18 changes: 18 additions & 0 deletions src/EnvironmentVariable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Kiboko\Component\Dockerfile;

final readonly class EnvironmentVariable implements Variable
{
public function __construct(
public string $name,
) {
}

public function __toString()
{
return "\${{$this->name}}";
}
}
25 changes: 25 additions & 0 deletions src/PHP/ComposerGlobalConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace Kiboko\Component\Dockerfile\PHP;

use Kiboko\Component\Dockerfile\Dockerfile;
use Kiboko\Component\Dockerfile\Variable;

final readonly class ComposerGlobalConfig implements Dockerfile\LayerInterface, \Stringable
{
public function __construct(
private string $key,
private string|Variable $value,
) {
}

public function __toString(): string
{
return (string) new Dockerfile\Run(<<<"RUN"
composer config --global {$this->key} {$this->value}
RUN
);
}
}
25 changes: 25 additions & 0 deletions src/PHP/ComposerGlobalGithubAuthentication.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace Kiboko\Component\Dockerfile\PHP;

use Kiboko\Component\Dockerfile\Dockerfile;
use Kiboko\Component\Dockerfile\Variable;

final readonly class ComposerGlobalGithubAuthentication implements Dockerfile\LayerInterface, \Stringable
{
public function __construct(
private Variable $tokenArgument,
private string $host = 'github.com',
) {
}

public function __toString(): string
{
return (string) new Dockerfile\Run(<<<"RUN"
composer config --global github-oauth.{$this->host} {$this->tokenArgument}
RUN,
);
}
}
9 changes: 9 additions & 0 deletions src/Variable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace Kiboko\Component\Dockerfile;

interface Variable extends \Stringable
{
}