-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from Ph3nol/jekyll
Jekyll Service
- Loading branch information
Showing
7 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
name: Docker Arch - Jekyll Project | ||
services: | ||
# Jekyll App | ||
- type: jekyll | ||
path: ../app | ||
host: localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
app/* | ||
!app/.gitkeep |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace Ph3\DockerArch\Application\DockerContainer; | ||
|
||
use Ph3\DockerArch\Domain\DockerContainer\Model\DockerContainer; | ||
use Ph3\DockerArch\Domain\DockerContainer\Model\DockerContainerInterface; | ||
use Ph3\DockerArch\Domain\TemplatedFile\Model\TemplatedFile; | ||
|
||
/** | ||
* @author Cédric Dugat <[email protected]> | ||
*/ | ||
class JekyllDockerContainer extends DockerContainer | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getPackageManager(): string | ||
{ | ||
return DockerContainerInterface::PACKAGE_MANAGER_TYPE_APK; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function execute(): void | ||
{ | ||
$service = $this->getService(); | ||
|
||
$this->setFrom('jekyll/jekyll:latest'); | ||
|
||
$this->setWorkingDir($this->getMainPath()); | ||
|
||
// EntryPoint. | ||
$service | ||
->addTemplatedFile(new TemplatedFile( | ||
'entrypoint.sh', | ||
'Service/Jekyll/entrypoint.sh.twig' | ||
)); | ||
$this | ||
->addCopyEntry([ | ||
'local' => 'entrypoint.sh', | ||
'remote' => '/root/entrypoint.sh', | ||
]) | ||
->addCommand('chmod +x /root/entrypoint.sh') | ||
->setEntryPoint(['/root/entrypoint.sh']); | ||
|
||
// Ports. | ||
$this->addEnvPort('JEKYLL', ['from' => '4004', 'to' => '4000']); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function postExecute(): void | ||
{ | ||
// UI. | ||
$port = reset($this->getService()->getDockerContainer()->getPorts()); | ||
$this->getService()->addUIAccess([ | ||
'url' => 'localhost', | ||
'port' => $port['from'], | ||
'label' => 'Website (from Watching)', | ||
]); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Application/Resources/views/Service/Jekyll/entrypoint.sh.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{% set mainPath = service.dockerContainer.mainPath %} | ||
#!/bin/sh | ||
set -e | ||
|
||
chown jekyll:jekyll {{ mainPath }} | ||
|
||
if [ ! -f "{{ mainPath }}/_config.yml" ]; then | ||
echo "--> No Jekyll project - Let's creating it..." | ||
jekyll new . | ||
fi | ||
|
||
jekyll serve |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Ph3\DockerArch\Application\Service; | ||
|
||
use Ph3\DockerArch\Domain\Service\Model\AbstractService; | ||
use Symfony\Component\OptionsResolver\Options; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
/** | ||
* @author Cédric Dugat <[email protected]> | ||
*/ | ||
class JekyllService extends AbstractService implements WebInterface, CliInterface | ||
{ | ||
const NAME = 'jekyll'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getOptionsResolver(): Options | ||
{ | ||
return new OptionsResolver(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters