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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ It's meant to be used with image geekstuffreal/php-fpm-alpine and the
To fully see how it's used, head over to https://github.com/geekstuff-it/docker-php-fpm-alpine

## TODO
- add laravel specifics
- add other installers (silex?)
- fix issue where new project got latest tag for php-fpm
- add env var in base nginx box to let us control the timeouts differently in dev and prod.
(in dev, we will put a long timeout to avoid nginx getting in the way with xdebug)
13 changes: 9 additions & 4 deletions src/Command/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\HttpClient\HttpClient;
Expand Down Expand Up @@ -167,10 +168,14 @@ protected function isRoot(): bool

protected function detectFramework(): string
{
if (file_exists($this->config->appDir.'/symfony.lock')) {
return $this->data::FRAMEWORK_SYMFONY;
} else {
return $this->data::FRAMEWORK_NONE;
$fs = new Filesystem();
switch (true) {
case $fs->exists($this->config->appDir.'/symfony.lock'):
return $this->data::FRAMEWORK_SYMFONY;
case $fs->exists($this->config->appDir.'/artisan'):
return $this->data::FRAMEWORK_LARAVEL;
default:
return $this->data::FRAMEWORK_NONE;
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/Command/Dockerize.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ protected function writeFiles(InputInterface $input, OutputInterface $output): b
$frameworkVersion = sprintf('framework/%s/%s', $framework, $templateFile->getFilename());
if ($fs->exists($this->config->rootDir . '/templates/dockerizer/' . $frameworkVersion)) {
$template = $frameworkVersion;
$output->writeln(sprintf(
'- with %s specifics, [%s]',
ucfirst($framework),
$templateFile->getFilenameWithoutExtension()
));
} else {
$output->writeln(sprintf('- [%s]', $templateFile->getFilenameWithoutExtension()));
}
}

Expand All @@ -163,7 +170,6 @@ protected function doneMessage(OutputInterface $output): bool
$message = $this->getTwig($this->getOtherTemplateDir())->render(
'dockerize-done.twig',
[
'FILE_LIST' => $this->getDockerizeTemplateFiles(),
'NOTES_FILENAME' => $notesFileBasename
]
);
Expand Down
9 changes: 8 additions & 1 deletion templates/dockerizer/Dockerfile.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ ARG NGINX_VERSION={{ NGINX_VERSION }}
FROM {{ FPM_FROM }}:${PHP_GEEKSTUFF_VERSION} AS base

{% block base %}
RUN docker-php-ext-install \
mysqli \
pdo_mysql \
&& docker-php-source delete

{% block base_extras %}{% endblock %}
{% endblock %}

Expand Down Expand Up @@ -94,8 +99,10 @@ RUN create-php-user ${PHP_USER_ID} \
## Copy code
COPY --chown=${PHP_USER_NAME}:${PHP_USER_NAME} . /app

## Init & Optimise app
## Switch to user
USER ${PHP_USER_NAME}

## Build and optimise app
{% block build_framework %}
RUN composer install --no-dev
{% endblock %}
Expand Down
24 changes: 24 additions & 0 deletions templates/dockerizer/framework/laravel/Dockerfile.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% extends "Dockerfile.twig" %}

{% block buildtools_extras %}
# npm
RUN apk add --update --no-cache \
nodejs \
npm \
yarn
{% endblock %}

{% block build_framework %}
RUN composer install --no-dev --optimize-autoloader \
&& php artisan config:cache \
&& php artisan view:cache \
&& php artisan event:cache \
&& php artisan storage:link

RUN yarn

# RUN npm run prod
# && php artisan route:cache \
# && composer dump-env prod \
# && composer dump-autoload --no-dev --classmap-authoritative
{% endblock %}
3 changes: 2 additions & 1 deletion templates/dockerizer/framework/symfony/Dockerfile.twig
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{% extends "Dockerfile.twig" %}

{% block build_framework %}
RUN composer install --no-dev \
RUN composer install --no-dev --optimize-autoloader \
&& bin/console cache:clear --env=prod \
&& bin/console cache:warmup --env=prod \
&& bin/console assets:install public \
&& composer dump-env prod \
&& composer dump-autoload --no-dev --classmap-authoritative
Expand Down
8 changes: 1 addition & 7 deletions templates/message/dockerize-done.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@
#### Dockerize complete!
You now have a multi-stage, multi-purpose Dockerfile, kept as lean as possible in every end stages, and 2 docker-compose configs.

## Details
These are the files that dockerize added:
{% for file in FILE_LIST %}
{{ file.getFilenameWithoutExtension }}
{% endfor %}
{{ NOTES_FILENAME }} (a copy of this "Dockerize complete" output)

## Easy DEV
`docker-compose up --build` and `docker-compose run php bash` should let you continue to build and run anything.

Expand All @@ -25,3 +18,4 @@ Because we have 2 separate image that don't need to share a volume in between th

## What's next?
Now you might still be in the init phase. Simply exit and start using docker-compose on your project!
(and these notes above have been written to {{ NOTES_FILENAME }})