Skip to content
Snippets Groups Projects
Commit b1655295 authored by jurgenhaas's avatar jurgenhaas
Browse files

Add support for LAKEDROPS_BUILD_NG

parent d8e48915
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ namespace LakeDrops\Docker4Drupal;
use Exception;
use LakeDrops\Component\Composer\BaseHandler;
use LakeDrops\DockerTraefik\Traefik;
use LakeDrops\DrupalEnvironment\Handler as DrupalEnvironment;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Yaml\Yaml;
......@@ -162,6 +163,36 @@ class Handler extends BaseHandler {
}
$options['projectroot'] = $projectRoot;
$options['projectdomain'] = $options['projectname'] . '.' . $options['traefik']['domain'];
$options['projectprotocol'] = 'http' . ($options['traefik']['usessl'] ? 's' : '');
$options['projectport'] = '';
if ($options['traefik']['usessl'] && (int) $options['traefik']['ports'] !== 443) {
$options['projectport'] = ':' . $options['traefik']['ports'];
}
else if (!$options['traefik']['usessl'] && (int) $options['traefik']['port'] !== 80) {
$options['projectport'] = ':' . $options['traefik']['port'];
}
// Update config for production build.
if (getenv('LAKEDROPS_BUILD_NG') === 'yes' && $this->getPackage('lakedrops/drupal-environment')) {
$handler = new DrupalEnvironment($this->composer, $this->io);
$config = $handler->getConfig();
$options['drupal'] += [
'live' => $config->readValue('live'),
];
$root = '/drupal/' . getenv('CI_PROJECT_ID') . '/' . getenv('CI_COMMIT_BRANCH');
$options['projectroot'] = $root . '/app';
$options['projectrootdb'] = $root . '/db';
$options['projectrootfiles'] = $root . '/files';
$options['projectname'] = getenv('CI_PROJECT_ID') . '-' . getenv('CI_COMMIT_BRANCH');
$options['projectdomain'] = $config->readValue('domain');
$options['projectprotocol'] = 'https';
$options['projectport'] = '';
$options['extradomains'] = $config->readValue('aliases');
$options['traefik']['usessl'] = 1;
$options['traefik']['ports'] = 443;
}
return $options;
}
......@@ -297,7 +328,9 @@ class Handler extends BaseHandler {
$this->gitIgnore('tests/backstop/backstop_data/html_report');
$this->gitLFS('tests/backstop/**/*.png');
$this->updateTraefik();
if (getenv('LAKEDROPS_BUILD_NG') !== 'yes') {
$this->updateTraefik();
}
// Set permissions, see https://wodby.com/stacks/drupal/docs/local/permissions
exec('setfacl -dR -m u:$(whoami):rwX -m u:82:rwX -m u:100:rX -m g::rwX ' . $projectRoot . ' >/dev/null 2>&1');
......
dev:
root: '/var/www/html/{{ webRoot }}/'
uri: '{{ projectname }}.{{ traefik.domain }}{% if traefik.usessl and traefik.ports != 443 %}:{{ traefik.ports }}{% elseif not traefik.usessl and traefik.port != 80 %}:{{ traefik.port }}{% endif %}'
uri: '{{ projectdomain }}{{ projectport }}'
behat:
root: '/var/www/html/{{ webRoot }}/'
uri: '{{ webserver.type }}'
......
......@@ -14,7 +14,12 @@ services:
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
MYSQL_LOG_CONSOLE: 0
{% if drupal.live|default(0) %}
volumes:
- {{ projectrootdb }}:/var/lib/mysql
{% endif %}
{% if not drupal.live|default(0) %}
mariadbtest:
image: {% if dbserver.type == 'mariadb' %}'wodby/mariadb:{{ dbserver.version }}'{% elseif dbserver.type == 'mysql' %}'mysql/mysql-server:{{ dbserver.version }}'{% else %}''{% endif %}
......@@ -24,6 +29,7 @@ services:
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
MYSQL_LOG_CONSOLE: 0
{% endif %}
php:
image: 'wodby/drupal-php:{{ php.version }}'
......@@ -35,7 +41,7 @@ services:
DB_NAME: drupal
DB_DRIVER: mysql
COMPOSER_ALLOW_SUPERUSER: 1
{% if php.xdebug %}
{% if php.xdebug and not drupal.live|default(0) %}
PHP_XDEBUG: 1
PHP_XDEBUG_MAX_NESTING_LEVEL: 512
PHP_XDEBUG_MODE: {% if php.coverage %}coverage{% else %}debug{% endif %}
......@@ -54,26 +60,30 @@ services:
PHP_XDEBUG_TRACE_OUTPUT_DIR: /mnt/files/xdebug/traces
{% endif %}
{% endif %}
{% if blackfire.enable %}
{% if blackfire.enable and not drupal.live|default(0) %}
PHP_BLACKFIRE: 1
{% endif %}
{% if php.ssh %}
{% if php.ssh and not drupal.live|default(0) %}
SSH_AUTH_SOCK: /ssh-agent
{% endif %}
volumes:
- {{ projectroot }}:/var/www/html
- {{ projectroot }}/drush:/etc/drush
{% if php.ssh %}
{% if drupal.live|default(0) %}
- {{ projectrootfiles }}/public:/var/www/html/files/default/files
- {{ projectrootfiles }}/private:/var/www/html/files/default/private
{% endif %}
{% if php.ssh and not drupal.live|default(0) %}
- {{ php.ssh_auth_sock }}:/ssh-agent
{% endif %}
{% if webgrind.enable %}
{% if webgrind.enable and not drupal.live|default(0) %}
- files:/mnt/files
{% endif %}
{% if wkhtmltox.enable %}
- './.docker-init/wkhtmltox.sh:/docker-entrypoint-init.d/50-wkhtmltox.sh'
{% endif %}
extra_hosts:
- '{{ projectname }}.{{ traefik.domain }}:{{ docker0.ip }}'
- '{{ projectdomain }}:{{ docker0.ip }}'
{{ webserver.type }}:
image: {% if webserver.type == 'nginx' %}'wodby/drupal-nginx:{{ webserver.version|default("1.21") }}'{% elseif webserver.type == 'apache' %}'wodby/apache:2.4'{% endif %}
......@@ -101,10 +111,14 @@ services:
{{ webserver.type|upper }}_SERVER_ROOT: /var/www/html/{{ webRoot }}/
volumes:
- {{ projectroot }}:/var/www/html
{% if drupal.live|default(0) %}
- {{ projectrootfiles }}/public:/var/www/html/files/default/files
- {{ projectrootfiles }}/private:/var/www/html/files/default/private
{% endif %}
labels:
traefik.enable: 'true'
traefik.docker.network: traefik-public
traefik.http.routers.{{ webserver.type }}-{{ projectname }}.rule: Host(`{{ projectname }}.{{ traefik.domain }}`){% for domain in extradomains|default([]) %} || Host(`{{ domain }}`){% endfor %}
traefik.http.routers.{{ webserver.type }}-{{ projectname }}.rule: Host(`{{ projectdomain }}`){% for domain in extradomains|default([]) %} || Host(`{{ domain }}`){% endfor %}
{% if varnish.enable %}
varnish:
......@@ -121,12 +135,13 @@ services:
labels:
traefik.enable: 'true'
traefik.docker.network: traefik-public
traefik.http.routers.varnish-{{ projectname }}.rule: Host(`varnish-{{ projectname }}.{{ traefik.domain }}`)
traefik.http.routers.varnish-{{ projectname }}.rule: Host(`varnish-{{ projectdomain }}`)
{% endif %}
redis:
image: 'wodby/redis:{{ redis.version }}'
{% if not drupal.live|default(0) %}
{% if dbbrowser.type == 'adminer' %}
adminer:
image: 'wodby/adminer:{{ dbbrowser.version|default("4.6") }}'
......@@ -139,7 +154,7 @@ services:
traefik.enable: 'true'
traefik.docker.network: traefik-public
traefik.http.services.{{ projectname }}_adminer.loadbalancer.server.port: 9000
traefik.http.routers.adminer-{{ projectname }}.rule: Host(`adminer-{{ projectname }}.{{ traefik.domain }}`)
traefik.http.routers.adminer-{{ projectname }}.rule: Host(`adminer-{{ projectdomain }}`)
{% elseif dbbrowser.type == 'pma' %}
pma:
image: 'phpmyadmin/phpmyadmin:latest'
......@@ -157,7 +172,8 @@ services:
labels:
traefik.enable: 'true'
traefik.docker.network: traefik-public
traefik.http.routers.pma-{{ projectname }}.rule: Host(`pma-{{ projectname }}.{{ traefik.domain }}`)
traefik.http.routers.pma-{{ projectname }}.rule: Host(`pma-{{ projectdomain }}`)
{% endif %}
{% endif %}
{% if solr.enable %}
......@@ -172,9 +188,10 @@ services:
traefik.enable: 'true'
traefik.docker.network: traefik-public
traefik.http.services.{{ projectname }}_solr.loadbalancer.server.port: 8983
traefik.http.routers.solr-{{ projectname }}.rule: Host(`solr-{{ projectname }}.{{ traefik.domain }}`)
traefik.http.routers.solr-{{ projectname }}.rule: Host(`solr-{{ projectdomain }}`)
{% endif %}
{% if not drupal.live|default(0) %}
mailhog:
image: 'mailhog/mailhog'
networks:
......@@ -189,7 +206,7 @@ services:
traefik.enable: 'true'
traefik.docker.network: traefik-public
traefik.http.services.{{ projectname }}_mailhog.loadbalancer.server.port: 8025
traefik.http.routers.mailhog-{{ projectname }}.rule: Host(`mailhog-{{ projectname }}.{{ traefik.domain }}`)
traefik.http.routers.mailhog-{{ projectname }}.rule: Host(`mailhog-{{ projectdomain }}`)
{% if node.enable %}
nodejs:
......@@ -203,7 +220,7 @@ services:
traefik.enable: 'true'
traefik.docker.network: traefik-public
traefik.http.services.{{ projectname }}_nodejs.loadbalancer.server.port: 8080
traefik.http.routers.nodejs-{{ projectname }}.rule: Host(`nodejs-{{ projectname }}.{{ traefik.domain }}`)
traefik.http.routers.nodejs-{{ projectname }}.rule: Host(`nodejs-{{ projectdomain }}`)
volumes:
- {{ projectroot }}/{{ node.path }}:/app
command: sh -c 'npm install && npm run start'
......@@ -218,13 +235,14 @@ services:
traefik.enable: 'true'
traefik.docker.network: traefik-public
traefik.http.services.{{ projectname }}_node.loadbalancer.server.port: 3000
traefik.http.routers.node-{{ projectname }}.rule: Host(`front-{{ projectname }}.{{ traefik.domain }}`)
traefik.http.routers.node-{{ projectname }}.rule: Host(`front-{{ projectdomain }}`)
expose:
- '3000'
volumes:
- {{ projectroot }}/{{ node.path }}:/app
command: sh -c 'npm install && npm run start'
{% endif %}
{% endif %}
{% if memcached.enable %}
memcached:
......@@ -247,7 +265,7 @@ services:
WEAVER_WORKER_TIMEOUT: 90
WEAVER_CONVERSION_FALLBACK: false
{% endif %}
{% if blackfire.enable %}
{% if blackfire.enable and not drupal.live|default(0) %}
blackfire:
image: 'blackfire/blackfire'
......@@ -255,7 +273,7 @@ services:
BLACKFIRE_SERVER_ID: '{{ blackfire.id }}'
BLACKFIRE_SERVER_TOKEN: '{{ blackfire.token }}'
{% endif %}
{% if webgrind.enable %}
{% if webgrind.enable and not drupal.live|default(0) %}
webgrind:
# add XDEBUG_PROFILE=1 to your request to profile that
......@@ -269,11 +287,11 @@ services:
traefik.enable: 'true'
traefik.docker.network: traefik-public
traefik.http.services.{{ projectname }}_webgrind.loadbalancer.server.port: 8080
traefik.http.routers.webgrind-{{ projectname }}.rule: Host(`webgrind-{{ projectname }}.{{ traefik.domain }}`)
traefik.http.routers.webgrind-{{ projectname }}.rule: Host(`webgrind-{{ projectdomain }}`)
volumes:
- {{ projectroot }}/files:/mnt/files
{% endif %}
{% if selenium.enable %}
{% if selenium.enable and not drupal.live|default(0) %}
hub:
image: 'elgalu/selenium'
......
......@@ -3,7 +3,7 @@ drush:
config:
- '${env.home}/.drush/config/drush.yml'
options:
uri: 'http{% if traefik.usessl %}s{% endif %}://{{ projectname }}.{{ traefik.domain }}{% if traefik.usessl and traefik.ports != 443 %}:{{ traefik.ports }}{% elseif not traefik.usessl and traefik.port != 80 %}:{{ traefik.port }}{% endif %}'
uri: '{{ projectprotocol }}://{{ projectdomain }}{{ projectport }}'
command:
core:
rsync:
......
......@@ -6,11 +6,13 @@ $settings['reverse_proxy'] = TRUE;
$settings['reverse_proxy_addresses'] = array("{{ docker0.proxy }}");
{% endif %}
$settings['trusted_host_patterns'] = array(
'^{{ projectname }}\.{{ traefik.domain|replace({".": "\\."}) }}$',
'^{{ webserver.type }}$',
'^{{ projectdomain|replace({".": "\\."}) }}$',
{% for domain in extradomains|default([]) %}
'^{{ domain|replace({".": "\\."}) }}$',
{% endfor %}
{% if not drupal.live|default(0) %}
'^{{ webserver.type }}$',
{% endif %}
);
$databases = array(
'default' => array(
......@@ -29,12 +31,14 @@ $databases = array(
),
),
);
{% if not drupal.live|default(0) %}
$config['smtp.settings']['smtp_host'] = 'mailhog';
$config['smtp.settings']['smtp_hostbackup'] = '';
$config['smtp.settings']['smtp_port'] = '1025';
$config['smtp.settings']['smtp_protocol'] = 'standard';
$config['smtp.settings']['smtp_username'] = '';
$config['smtp.settings']['smtp_password'] = '';
{% endif %}
{% elseif drupal.version <= 7 %}
$databases = array(
'default' => array(
......@@ -52,7 +56,7 @@ $databases = array(
),
);
$base_url = 'http{% if traefik.usessl %}s{% endif %}://{{ projectname }}.{{ traefik.domain }}{% if traefik.usessl and traefik.ports != 443 %}:{{ traefik.ports }}{% elseif not traefik.usessl and traefik.port != 80 %}:{{ traefik.port }}{% endif %}';
$base_url = '{{ projectprotocol }}://{{ projectdomain }}{{ projectport }}';
$conf['smtp_host'] = 'mailhog';
$conf['smtp_hostbackup'] = '';
$conf['smtp_port'] = '1025';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment