Commit 8a6a2916 authored by Jürgen Haas's avatar Jürgen Haas

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/Handler.php
parents c0b91188 ce375431
......@@ -8,6 +8,7 @@ commands:
docker-compose exec --user root php drush sql:sync --create-db @default.live @default.dev
docker-compose exec --user root php drush @default.dev cr
docker-compose exec --user root php drush @default.dev dev on
docker-compose exec --user root php drush @default.dev cim --partial --source=/var/www/html/config/default/environments/develop
docker-compose exec --user root php drush rsync @default.live:%files/ @default.dev:%files -- --chown=www-data:www-data --safe-links --max-size=20M
usage: Pull files and DB from live site
pull-sql:
......@@ -15,6 +16,7 @@ commands:
docker-compose exec --user root php drush sql:sync --create-db @default.live @default.dev
docker-compose exec --user root php drush @default.dev cr
docker-compose exec --user root php drush @default.dev dev on
docker-compose exec --user root php drush @default.dev cim --partial --source=/var/www/html/config/default/environments/develop
usage: Pull DB from live site
pull-files:
cmd: |
......
......@@ -24,6 +24,7 @@
"source": "https://gitlab.lakedrops.com/composer/plugin/docker4drupal/tree/master"
},
"require": {
"ext-json": "*",
"php": ">=5.6",
"composer-plugin-api": "^1.0.0",
"lakedrops/composer-scripts": "^1.1.0",
......
......@@ -210,6 +210,7 @@ class Handler extends BaseHandler {
$extra = $this->composer->getPackage()->getExtra() + ['docker4drupal' => []];
$options = NestedArray::mergeDeep([
'projectname' => $projectname,
'ci_home' => '/home/gitlab-runner',
'docker0' => [
'ip' => $this->getLocalIpv4('docker0'),
],
......@@ -286,6 +287,16 @@ class Handler extends BaseHandler {
'enable' => 0,
],
], $extra['docker4drupal']);
$projectRoot = getenv('CI_PROJECT_DIR');
if (empty($projectRoot)) {
$projectRoot = getcwd();
}
else {
$projectRoot = $this->getDockerMountSource($projectRoot);
}
$options['projectroot'] = $projectRoot;
$this->options = $env->replaceEnvironmentVariables($options);
}
if ($key !== NULL) {
......@@ -326,4 +337,29 @@ class Handler extends BaseHandler {
return isset($local_addrs[$interface]) ? $local_addrs[$interface] : '127.0.0.1';
}
/**
* @param $projectRoot
*
* @return string
*/
private function getDockerMountSource($projectRoot) {
try {
$output = [];
exec('basename "$(cat /proc/1/cpuset)"', $output);
$id = reset($output);
$output = [];
exec('docker container inspect ' . $id, $output);
$container = json_decode(implode('', $output), TRUE)[0];
foreach ($container['Mounts'] as $mount) {
if (strpos($projectRoot, $mount['Destination']) === 0) {
return $mount['Source'] . substr($projectRoot, strlen($mount['Destination']));
}
}
}
catch (\Exception $ex) {
// Ignore.
}
return getcwd();
}
}
......@@ -18,6 +18,7 @@ services:
DB_PASSWORD: drupal
DB_NAME: drupal
DB_DRIVER: mysql
COMPOSER_ALLOW_SUPERUSER: 1
{% if php.xdebug %}
PHP_XDEBUG: 1
PHP_XDEBUG_DEFAULT_ENABLE: 1
......@@ -41,8 +42,8 @@ services:
SSH_AUTH_SOCK: /ssh-agent
{% endif %}
volumes:
- ./:/var/www/html
- ./drush:/etc/drush
- {{ projectroot }}:/var/www/html
- {{ projectroot }}/drush:/etc/drush
{% if php.ssh %}
- $SSH_AUTH_SOCK:/ssh-agent
{% endif %}
......@@ -77,7 +78,7 @@ services:
{{ webserver.type|upper }}_BACKEND_HOST: php
{{ webserver.type|upper }}_SERVER_ROOT: /var/www/html/{{ webRoot }}
volumes:
- ./:/var/www/html
- {{ projectroot }}:/var/www/html
labels:
traefik.backend: '{{ projectname }}_{{ webserver.type }}_1'
traefik.port: '80'
......@@ -153,7 +154,7 @@ services:
traefik.port: '8080'
traefik.frontend.rule: 'Host:nodejs.{{ projectname }}.docker.localhost'
volumes:
- ./{{ node.path }}:/app
- {{ projectroot }}/{{ node.path }}:/app
command: sh -c 'npm install && npm run start'
node:
......@@ -166,7 +167,7 @@ services:
expose:
- '3000'
volumes:
- ./{{ node.path }}:/app
- {{ projectroot }}/{{ node.path }}:/app
command: sh -c 'npm install && npm run start'
{% endif %}
{% if memcached.enable %}
......@@ -211,7 +212,7 @@ services:
traefik.port: '8080'
traefik.frontend.rule: 'Host:webgrind.{{ projectname }}.docker.localhost'
volumes:
- files:/mnt/files
- {{ projectroot }}/files:/mnt/files
{% endif %}
hub:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment