Skip to content

Commit

Permalink
Docker: pass SSH auth socket into container
Browse files Browse the repository at this point in the history
  • Loading branch information
borsboom committed Jan 30, 2016
1 parent 2e319cd commit cea6e03
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Major changes:

Other enhancements:

* Docker: pass SSH auth socket into container

Bug fixes:

* Previously, `stack ghci` would fail with `cannot satisfy -package-id` when the
Expand Down
21 changes: 14 additions & 7 deletions src/Stack/Docker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ import Stack.Types
import Stack.Types.Internal
import Stack.Setup (ensureDockerStackExe)
import System.Directory (canonicalizePath,getModificationTime)
import System.Environment (getEnv,getProgName,getArgs,getExecutablePath,lookupEnv)
import System.Environment (getEnv,getEnvironment,getProgName,getArgs,getExecutablePath
,lookupEnv)
import System.Exit (exitSuccess, exitWith)
import qualified System.FilePath as FP
import System.IO (stderr,stdin,stdout,hIsTerminalDevice)
Expand Down Expand Up @@ -256,12 +257,13 @@ runContainerAndExit getCmdArgs
let docker = configDocker config
envOverride <- getEnvOverride (configPlatform config)
checkDockerVersion envOverride docker
(dockerHost,dockerCertPath,bamboo,jenkins) <-
liftIO ((,,,) <$> lookupEnv "DOCKER_HOST"
<*> lookupEnv "DOCKER_CERT_PATH"
<*> lookupEnv "bamboo_buildKey"
<*> lookupEnv "JENKINS_HOME")
let isRemoteDocker = maybe False (isPrefixOf "tcp://") dockerHost
env <- liftIO getEnvironment
let dockerHost = lookup "DOCKER_HOST" env
dockerCertPath = lookup "DOCKER_CERT_PATH" env
bamboo = lookup "bamboo_buildKey" env
jenkins = lookup "JENKINS_HOME" env
msshAuthSock = lookup "SSH_AUTH_SOCK" env
isRemoteDocker = maybe False (isPrefixOf "tcp://") dockerHost
isStdoutTerminal <- asks getTerminal
(isStdinTerminal,isStderrTerminal) <-
liftIO ((,) <$> hIsTerminalDevice stdin
Expand Down Expand Up @@ -320,6 +322,11 @@ runContainerAndExit getCmdArgs
,"-v",toFilePathNoTrailingSep projectRoot ++ ":" ++ toFilePathNoTrailingSep projectRoot
,"-v",toFilePathNoTrailingSep sandboxHomeDir ++ ":" ++ toFilePathNoTrailingSep sandboxHomeDir
,"-w",toFilePathNoTrailingSep pwd]
,case msshAuthSock of
Nothing -> []
Just sshAuthSock ->
["-e","SSH_AUTH_SOCK=" ++ sshAuthSock
,"-v",sshAuthSock ++ ":" ++ sshAuthSock]
-- Disable the deprecated entrypoint in FP Complete-generated images
,["--entrypoint=/usr/bin/env"
| isJust (lookupImageEnv oldSandboxIdEnvVar imageEnvVars) &&
Expand Down

0 comments on commit cea6e03

Please sign in to comment.