Skip to content

Commit

Permalink
Merge pull request #23 from magento-commerce/develop
Browse files Browse the repository at this point in the history
Release 1.2.1
  • Loading branch information
oshmyheliuk authored Dec 17, 2020
2 parents 09872ff + 22fcd62 commit 0ca8dc1
Show file tree
Hide file tree
Showing 77 changed files with 1,937 additions and 77 deletions.
1 change: 1 addition & 0 deletions codeception.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ modules:
composer_magento_password: "%REPO_PASSWORD%"
composer_github_token: "%GITHUB_TOKEN%"
use_generated_images: false
generated_images_namespace: "cloudft"
use_cached_workdir: true
version_generated_images: "%TRAVIS_BUILD_NUMBER%"
printOutput: false
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "magento/magento-cloud-docker",
"description": "Magento Cloud Docker",
"type": "magento2-component",
"version": "1.2.0",
"version": "1.2.1",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
6 changes: 4 additions & 2 deletions images/nginx/1.19/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
FROM nginx
FROM nginx:1.19

ENV UPLOAD_MAX_FILESIZE 64M
ENV XDEBUG_HOST fpm_xdebug
ENV FPM_HOST fpm
ENV FPM_PORT 9000
ENV UPSTREAM_HOST web
ENV UPSTREAM_PORT 80
ENV UPSTREAM_PORT 8080
ENV MAGENTO_ROOT /app
ENV MAGENTO_RUN_MODE production
ENV MFTF_UTILS 0
ENV DEBUG false
ENV NGINX_WORKER_PROCESSES 1
ENV NGINX_WORKER_CONNECTIONS 1024

COPY etc/nginx.conf /etc/nginx/
COPY etc/vhost.conf /etc/nginx/conf.d/default.conf
Expand Down
2 changes: 2 additions & 0 deletions images/nginx/1.19/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ XDEBUG_UPSTREAM_FILE="/etc/nginx/conf.d/xdebug/upstream.conf"
[ ! -z "${UPLOAD_MAX_FILESIZE}" ] && sed -i "s/!UPLOAD_MAX_FILESIZE!/${UPLOAD_MAX_FILESIZE}/" $VHOST_FILE
[ ! -z "${WITH_XDEBUG}" ] && sed -i "s/!WITH_XDEBUG!/${WITH_XDEBUG}/" $VHOST_FILE
[ "${WITH_XDEBUG}" == "1" ] && sed -i "s/#include_xdebug_upstream/include/" $NGINX_FILE
[ ! -z "${NGINX_WORKER_PROCESSES}" ] && sed -i "s/!NGINX_WORKER_PROCESSES!/${NGINX_WORKER_PROCESSES}/" $NGINX_FILE
[ ! -z "${NGINX_WORKER_CONNECTIONS}" ] && sed -i "s/!NGINX_WORKER_CONNECTIONS!/${NGINX_WORKER_CONNECTIONS}/" $NGINX_FILE

# Check if the nginx syntax is fine, then launch.
nginx -t
Expand Down
4 changes: 2 additions & 2 deletions images/nginx/1.19/etc/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
worker_processes 2;
worker_processes !NGINX_WORKER_PROCESSES!;

error_log /var/log/nginx/error.log debug;
pid /var/run/nginx.pid;

events {
# this should be equal to value of "ulimit -n"
# reference: https://www.digitalocean.com/community/tutorials/how-to-optimize-nginx-configuration
worker_connections 1048576;
worker_connections !NGINX_WORKER_CONNECTIONS!;
}

http {
Expand Down
3 changes: 1 addition & 2 deletions images/php/7.2-cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire
&& mkdir -p /tmp/blackfire \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
&& mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \
&& ( echo extension=blackfire.so \
&& echo blackfire.agent_socket=tcp://blackfire:8707 ) > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \
&& echo blackfire.agent_socket=tcp://blackfire:8707 > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz
RUN rm -f /usr/local/etc/php/conf.d/*sodium.ini \
&& rm -f /usr/local/lib/php/extensions/*/*sodium.so \
Expand Down
3 changes: 1 addition & 2 deletions images/php/7.2-fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire
&& mkdir -p /tmp/blackfire \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
&& mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \
&& ( echo extension=blackfire.so \
&& echo blackfire.agent_socket=tcp://blackfire:8707 ) > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \
&& echo blackfire.agent_socket=tcp://blackfire:8707 > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz
RUN rm -f /usr/local/etc/php/conf.d/*sodium.ini \
&& rm -f /usr/local/lib/php/extensions/*/*sodium.so \
Expand Down
2 changes: 1 addition & 1 deletion images/php/7.2-fpm/fpm-healthcheck.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -eo pipefail

fpm_response=$(curl -o /dev/null -s -w "%{http_code}\n" http://${WEB_HOST:-web}:${WEB_PORT:-80}/status)
fpm_response=$(curl -o /dev/null -s -w "%{http_code}\n" http://${WEB_HOST:-web}:${WEB_PORT:-8080}/status)

if [ "$fpm_response" == "200" ]
then
Expand Down
3 changes: 1 addition & 2 deletions images/php/7.3-cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire
&& mkdir -p /tmp/blackfire \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
&& mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \
&& ( echo extension=blackfire.so \
&& echo blackfire.agent_socket=tcp://blackfire:8707 ) > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \
&& echo blackfire.agent_socket=tcp://blackfire:8707 > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz
RUN rm -f /usr/local/etc/php/conf.d/*sodium.ini \
&& rm -f /usr/local/lib/php/extensions/*/*sodium.so \
Expand Down
3 changes: 1 addition & 2 deletions images/php/7.3-fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire
&& mkdir -p /tmp/blackfire \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
&& mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \
&& ( echo extension=blackfire.so \
&& echo blackfire.agent_socket=tcp://blackfire:8707 ) > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \
&& echo blackfire.agent_socket=tcp://blackfire:8707 > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz
RUN rm -f /usr/local/etc/php/conf.d/*sodium.ini \
&& rm -f /usr/local/lib/php/extensions/*/*sodium.so \
Expand Down
2 changes: 1 addition & 1 deletion images/php/7.3-fpm/fpm-healthcheck.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -eo pipefail

fpm_response=$(curl -o /dev/null -s -w "%{http_code}\n" http://${WEB_HOST:-web}:${WEB_PORT:-80}/status)
fpm_response=$(curl -o /dev/null -s -w "%{http_code}\n" http://${WEB_HOST:-web}:${WEB_PORT:-8080}/status)

if [ "$fpm_response" == "200" ]
then
Expand Down
3 changes: 1 addition & 2 deletions images/php/7.4-cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire
&& mkdir -p /tmp/blackfire \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
&& mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \
&& ( echo extension=blackfire.so \
&& echo blackfire.agent_socket=tcp://blackfire:8707 ) > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \
&& echo blackfire.agent_socket=tcp://blackfire:8707 > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz
RUN rm -f /usr/local/etc/php/conf.d/*sodium.ini \
&& rm -f /usr/local/lib/php/extensions/*/*sodium.so \
Expand Down
3 changes: 1 addition & 2 deletions images/php/7.4-fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire
&& mkdir -p /tmp/blackfire \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
&& mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \
&& ( echo extension=blackfire.so \
&& echo blackfire.agent_socket=tcp://blackfire:8707 ) > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \
&& echo blackfire.agent_socket=tcp://blackfire:8707 > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz
RUN rm -f /usr/local/etc/php/conf.d/*sodium.ini \
&& rm -f /usr/local/lib/php/extensions/*/*sodium.so \
Expand Down
2 changes: 1 addition & 1 deletion images/php/7.4-fpm/fpm-healthcheck.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -eo pipefail

fpm_response=$(curl -o /dev/null -s -w "%{http_code}\n" http://${WEB_HOST:-web}:${WEB_PORT:-80}/status)
fpm_response=$(curl -o /dev/null -s -w "%{http_code}\n" http://${WEB_HOST:-web}:${WEB_PORT:-8080}/status)

if [ "$fpm_response" == "200" ]
then
Expand Down
2 changes: 1 addition & 1 deletion images/php/fpm/fpm-healthcheck.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -eo pipefail

fpm_response=$(curl -o /dev/null -s -w "%{http_code}\n" http://${WEB_HOST:-web}:${WEB_PORT:-80}/status)
fpm_response=$(curl -o /dev/null -s -w "%{http_code}\n" http://${WEB_HOST:-web}:${WEB_PORT:-8080}/status)

if [ "$fpm_response" == "200" ]
then
Expand Down
17 changes: 17 additions & 0 deletions src/Command/BuildCompose.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,18 @@ protected function configure(): void
null,
InputOption::VALUE_NONE,
'Sets host.docker.internal for fpm_xdebug container to resolve debug issue for LINUX system'
)->addOption(
Source\CliSource::OPTION_NGINX_WORKER_PROCESSES,
null,
InputOption::VALUE_OPTIONAL,
'The number of NGINX worker processes',
Source\BaseSource::DEFAULT_NGINX_WORKER_PROCESSES
)->addOption(
Source\CliSource::OPTION_NGINX_WORKER_CONNECTIONS,
null,
InputOption::VALUE_OPTIONAL,
'The maximum number of connections that each worker process can handle simultaneously',
Source\BaseSource::DEFAULT_NGINX_WORKER_CONNECTIONS
);

$this->addOption(
Expand Down Expand Up @@ -261,6 +273,11 @@ protected function configure(): void
null,
InputOption::VALUE_REQUIRED,
'Port'
)->addOption(
Source\CliSource::OPTION_NO_TLS,
null,
InputOption::VALUE_NONE,
'Disable TLS'
)->addOption(
Source\CliSource::OPTION_TLS_PORT,
null,
Expand Down
6 changes: 3 additions & 3 deletions src/Compose/BuilderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ interface BuilderInterface
public const VOLUME_MAGENTO_DB_QUOTE = 'magento-db-quote';
public const VOLUME_MAGENTO_DB_SALES = 'magento-db-sales';
public const VOLUME_MAGENTO_DEV = './dev';
public const VOLUME_DOCKER_ETRYPOINT = '.docker/mysql/docker-entrypoint-initdb.d';
public const VOLUME_DOCKER_ETRYPOINT_QUOTE = '.docker/mysql-quote/docker-entrypoint-initdb.d';
public const VOLUME_DOCKER_ETRYPOINT_SALES = '.docker/mysql-sales/docker-entrypoint-initdb.d';
public const VOLUME_DOCKER_ENTRYPOINT = '.docker/mysql/docker-entrypoint-initdb.d';
public const VOLUME_DOCKER_ENTRYPOINT_QUOTE = '.docker/mysql-quote/docker-entrypoint-initdb.d';
public const VOLUME_DOCKER_ENTRYPOINT_SALES = '.docker/mysql-sales/docker-entrypoint-initdb.d';

public const SYNC_ENGINE_NATIVE = 'native';

Expand Down
13 changes: 2 additions & 11 deletions src/Compose/DeveloperBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace Magento\CloudDocker\Compose;

use Magento\CloudDocker\App\ConfigurationMismatchException;
use Magento\CloudDocker\Compose\Php\ExtensionResolver;
use Magento\CloudDocker\Config\Config;
use Magento\CloudDocker\Config\Environment\Converter;
Expand Down Expand Up @@ -97,14 +96,6 @@ public function build(Config $config): Manager
$volumes = [$volumePrefix . self::VOLUME_MAGENTO_SYNC . ':' . self::DIR_MAGENTO . ':nocopy'];
}

if ($config->hasMariaDbConf()) {
$volumesList[$volumePrefix . self::VOLUME_MARIADB_CONF] = [];
}

if ($config->hasDbEntrypoint()) {
$volumesList[self::VOLUME_DOCKER_ETRYPOINT] = [];
}

$manager->setVolumes($volumesList);

/**
Expand All @@ -129,11 +120,11 @@ public function build(Config $config): Manager
];

if ($config->hasMariaDbConf()) {
$dbVolumes[] = $volumePrefix . self::VOLUME_MARIADB_CONF . ':/etc/mysql/mariadb.conf.d';
$dbVolumes[] = self::VOLUME_MARIADB_CONF . ':/etc/mysql/mariadb.conf.d';
}

if ($config->hasDbEntrypoint()) {
$dbVolumes[] = self::VOLUME_DOCKER_ETRYPOINT . ':/docker-entrypoint-initdb.d';
$dbVolumes[] = self::VOLUME_DOCKER_ENTRYPOINT . ':/docker-entrypoint-initdb.d';
}

$manager->updateService(self::SERVICE_DB, [
Expand Down
5 changes: 2 additions & 3 deletions src/Compose/Php/ExtensionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ExtensionResolver
'sysvsem',
'sysvshm',
'opcache',
'zip',
'zip'
];

/**
Expand Down Expand Up @@ -172,8 +172,7 @@ public static function getConfig(): array
mkdir -p /tmp/blackfire
tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire
mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so
( echo extension=blackfire.so
echo blackfire.agent_socket=tcp://blackfire:8707 ) > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini
echo blackfire.agent_socket=tcp://blackfire:8707 > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini
rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz
BASH
// phpcs:enable
Expand Down
25 changes: 23 additions & 2 deletions src/Compose/ProductionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Magento\CloudDocker\Compose;

use Magento\CloudDocker\App\ConfigurationMismatchException;
use Magento\CloudDocker\Compose\ProductionBuilder\ServiceBuilderInterface;
use Magento\CloudDocker\Compose\ProductionBuilder\ServicePool;
use Magento\CloudDocker\Compose\ProductionBuilder\VolumeResolver;
use Magento\CloudDocker\Config\Config;
Expand Down Expand Up @@ -35,7 +37,6 @@ class ProductionBuilder implements BuilderInterface
self::SERVICE_GENERIC,
self::SERVICE_DEPLOY,
self::SERVICE_BUILD,
self::SERVICE_TLS,
self::SERVICE_WEB,
self::SERVICE_FPM,
self::SERVICE_DB,
Expand Down Expand Up @@ -91,7 +92,7 @@ public function build(Config $config): Manager
$manager = $this->managerFactory->create($config);

foreach ($this->servicePool->getServices() as $service) {
if ($config->hasServiceEnabled($service->getServiceName())
if ($this->hasServiceEnabled($service, $config)
|| in_array($service->getName(), self::$requiredServices)
) {
$manager->addService($service);
Expand Down Expand Up @@ -135,4 +136,24 @@ public function getPath(): string
{
return $this->fileList->getMagentoDockerCompose();
}

/**
* Checks the availability of the service
*
* @param ServiceBuilderInterface $service
* @param Config $config
* @return bool
* @throws ConfigurationMismatchException
*/
private function hasServiceEnabled(ServiceBuilderInterface $service, Config $config): bool
{
$serviceNames = [
BuilderInterface::SERVICE_FPM_XDEBUG,
BuilderInterface::SERVICE_DB_QUOTE,
BuilderInterface::SERVICE_DB_SALES,
];
$service = in_array($service->getName(), $serviceNames) ? $service->getServiceName() : $service->getName();

return $config->hasServiceEnabled($service);
}
}
2 changes: 1 addition & 1 deletion src/Compose/ProductionBuilder/Service/Database/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private function getMounts(Config $config): array
$mounts[] = $config->getNameWithPrefix() . BuilderInterface::VOLUME_MAGENTO_DB . ':/var/lib/mysql';

if ($config->hasDbEntrypoint()) {
$mounts[] = BuilderInterface::VOLUME_DOCKER_ETRYPOINT . ':/docker-entrypoint-initdb.d';
$mounts[] = BuilderInterface::VOLUME_DOCKER_ENTRYPOINT . ':/docker-entrypoint-initdb.d';
}

return $mounts;
Expand Down
2 changes: 1 addition & 1 deletion src/Compose/ProductionBuilder/Service/Database/DbQuote.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private function getMounts(Config $config): array
}

$mounts[] = BuilderInterface::VOLUME_MAGENTO_DB_QUOTE . ':/var/lib/mysql';
$mounts[] = BuilderInterface::VOLUME_DOCKER_ETRYPOINT_QUOTE . ':/docker-entrypoint-initdb.d';
$mounts[] = BuilderInterface::VOLUME_DOCKER_ENTRYPOINT_QUOTE . ':/docker-entrypoint-initdb.d';

return $mounts;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Compose/ProductionBuilder/Service/Database/DbSales.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private function getMounts(Config $config): array
}

$mounts[] = BuilderInterface::VOLUME_MAGENTO_DB_SALES . ':/var/lib/mysql';
$mounts[] = BuilderInterface::VOLUME_DOCKER_ETRYPOINT_SALES . ':/docker-entrypoint-initdb.d';
$mounts[] = BuilderInterface::VOLUME_DOCKER_ENTRYPOINT_SALES . ':/docker-entrypoint-initdb.d';

return $mounts;
}
Expand Down
27 changes: 26 additions & 1 deletion src/Compose/ProductionBuilder/Service/Tls.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getConfig(Config $config): array
'aliases' => [$config->getHost()]
]
],
'environment' => ['UPSTREAM_HOST' => $this->getBackendService($config)],
'environment' => $this->getEnvironmentVariables($config),
'ports' => [
$config->getPort() . ':80',
$config->getTlsPort() . ':443'
Expand Down Expand Up @@ -100,4 +100,29 @@ private function getBackendService(Config $config): string
? BuilderInterface::SERVICE_VARNISH
: BuilderInterface::SERVICE_WEB;
}

/**
* @param Config $config
* @return string[]
* @throws ConfigurationMismatchException
*/
private function getEnvironmentVariables(Config $config): array
{
$envVariables = [
'NGINX_WORKER_PROCESSES=' . $config->getNginxWorkerProcesses(),
'NGINX_WORKER_CONNECTIONS=' . $config->getNginxWorkerConnections(),
];

if ($config->hasServiceEnabled(ServiceInterface::SERVICE_VARNISH)) {
$envVariables[] = 'UPSTREAM_HOST=' . BuilderInterface::SERVICE_VARNISH;
$envVariables[] = 'UPSTREAM_PORT=80';

return $envVariables;
}

$envVariables[] = 'UPSTREAM_HOST=' . BuilderInterface::SERVICE_WEB;
$envVariables[] = 'UPSTREAM_PORT=8080';

return $envVariables;
}
}
Loading

0 comments on commit 0ca8dc1

Please sign in to comment.