From 58eb60b850104f7c9e47782d50529e833f333a1f Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Wed, 19 Dec 2018 14:22:10 +0100
Subject: [PATCH] Set the value of $SSH_AUTH_SOCK instead of the env variable
 so that the containers can be started from within the dev container as well

---
 src/Handler.php                   | 12 ++++++++----
 templates/docker-compose.yml.twig |  2 +-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/Handler.php b/src/Handler.php
index c546f3d..054d631 100644
--- a/src/Handler.php
+++ b/src/Handler.php
@@ -74,10 +74,6 @@ class Handler extends BaseHandler {
       $settingsPath = 'settings/default';
     }
 
-    // Check if SSH auth sockets are supported.
-    $ssh_auth_sock = getenv('SSH_AUTH_SOCK');
-    $options['php']['ssh'] = !empty($ssh_auth_sock);
-
     // Provide all the required files.
     $twig_loader = new \Twig_Loader_Array([]);
     $twig = new \Twig_Environment($twig_loader);
@@ -294,6 +290,14 @@ class Handler extends BaseHandler {
       else {
         $projectRoot = getcwd();
       }
+
+      // Check if SSH auth sockets are supported.
+      $ssh_auth_sock = getenv('SSH_AUTH_SOCK');
+      $options['php']['ssh'] = !empty($ssh_auth_sock);
+      if ($options['php']['ssh']) {
+        $options['php']['ssh_auth_sock'] = $this->getDockerMountSource('/ssh-agent');
+      }
+
       $options['projectroot'] = $projectRoot;
 
       $this->options = $env->replaceEnvironmentVariables($options);
diff --git a/templates/docker-compose.yml.twig b/templates/docker-compose.yml.twig
index 2bdcaa3..7476a5f 100644
--- a/templates/docker-compose.yml.twig
+++ b/templates/docker-compose.yml.twig
@@ -45,7 +45,7 @@ services:
       - {{ projectroot }}:/var/www/html
       - {{ projectroot }}/drush:/etc/drush
 {% if php.ssh %}
-      - $SSH_AUTH_SOCK:/ssh-agent
+      - {{ php.ssh_auth_sock }}:/ssh-agent
 {% endif %}
 {% if webgrind.enable %}
       - files:/mnt/files
-- 
GitLab