Skip to content

Commit

Permalink
symlink $HOME/.ssh
Browse files Browse the repository at this point in the history
  • Loading branch information
dysinger committed Apr 6, 2016
1 parent 7e5ba38 commit 3dd9a3e
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/Stack/Docker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,6 @@ runContainerAndExit getCmdArgs
<*> hIsTerminalDevice stderr
<*> (parseAbsDir =<< getHomeDirectory)
isStdoutTerminal <- asks getTerminal
let sshDir = homeDir </> sshRelDir
sshDirExists <- doesDirExist sshDir
let dockerHost = lookup "DOCKER_HOST" env
dockerCertPath = lookup "DOCKER_CERT_PATH" env
bamboo = lookup "bamboo_buildKey" env
Expand Down Expand Up @@ -309,6 +307,19 @@ runContainerAndExit getCmdArgs
liftIO
(do updateDockerImageLastUsed config iiId (toFilePath projectRoot)
mapM_ (ensureDir) [sandboxHomeDir, stackRoot])
-- Since $HOME is now mounted in the same place in the container we can
-- just symlink $HOME/.ssh to the right place for the stack docker user
let sshDir = homeDir </> sshRelDir
sshDirExists <- doesDirExist sshDir
sshSandboxDirExists <-
liftIO
(Files.fileExist
(toFilePathNoTrailingSep (sandboxHomeDir </> sshRelDir)))
when (sshDirExists && not sshSandboxDirExists)
(liftIO
(Files.createSymbolicLink
(toFilePathNoTrailingSep sshDir)
(toFilePathNoTrailingSep (sandboxHomeDir </> sshRelDir))))
containerID <- (trim . decodeUtf8) <$> readDockerProcess
envOverride
(concat
Expand All @@ -328,10 +339,6 @@ runContainerAndExit getCmdArgs
,case muserEnv of
Nothing -> []
Just userEnv -> ["-e","USER=" ++ userEnv]
,if sshDirExists
then ["-v",toFilePathNoTrailingSep sshDir ++ ":" ++
toFilePathNoTrailingSep (sandboxHomeDir </> sshRelDir)]
else []
,case msshAuthSock of
Nothing -> []
Just sshAuthSock ->
Expand Down

0 comments on commit 3dd9a3e

Please sign in to comment.