Skip to content

Commit 322160d

Browse files
dysingerborsboom
authored andcommitted
symlink $HOME/.ssh
1 parent 009bfc5 commit 322160d

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/Stack/Docker.hs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ runContainerAndExit getCmdArgs
260260
<*> hIsTerminalDevice stderr
261261
<*> (parseAbsDir =<< getHomeDirectory)
262262
isStdoutTerminal <- asks getTerminal
263-
let sshDir = homeDir </> sshRelDir
264-
sshDirExists <- doesDirExist sshDir
265263
let dockerHost = lookup "DOCKER_HOST" env
266264
dockerCertPath = lookup "DOCKER_CERT_PATH" env
267265
bamboo = lookup "bamboo_buildKey" env
@@ -309,6 +307,19 @@ runContainerAndExit getCmdArgs
309307
liftIO
310308
(do updateDockerImageLastUsed config iiId (toFilePath projectRoot)
311309
mapM_ (ensureDir) [sandboxHomeDir, stackRoot])
310+
-- Since $HOME is now mounted in the same place in the container we can
311+
-- just symlink $HOME/.ssh to the right place for the stack docker user
312+
let sshDir = homeDir </> sshRelDir
313+
sshDirExists <- doesDirExist sshDir
314+
sshSandboxDirExists <-
315+
liftIO
316+
(Files.fileExist
317+
(toFilePathNoTrailingSep (sandboxHomeDir </> sshRelDir)))
318+
when (sshDirExists && not sshSandboxDirExists)
319+
(liftIO
320+
(Files.createSymbolicLink
321+
(toFilePathNoTrailingSep sshDir)
322+
(toFilePathNoTrailingSep (sandboxHomeDir </> sshRelDir))))
312323
containerID <- (trim . decodeUtf8) <$> readDockerProcess
313324
envOverride
314325
(concat
@@ -328,10 +339,6 @@ runContainerAndExit getCmdArgs
328339
,case muserEnv of
329340
Nothing -> []
330341
Just userEnv -> ["-e","USER=" ++ userEnv]
331-
,if sshDirExists
332-
then ["-v",toFilePathNoTrailingSep sshDir ++ ":" ++
333-
toFilePathNoTrailingSep (sandboxHomeDir </> sshRelDir)]
334-
else []
335342
,case msshAuthSock of
336343
Nothing -> []
337344
Just sshAuthSock ->

0 commit comments

Comments
 (0)